@deepdesk/deepdesk-sdk 10.1.2 → 10.1.3

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 ld=Object.create;var fo=Object.defineProperty;var cd=Object.getOwnPropertyDescriptor;var ud=Object.getOwnPropertyNames;var pd=Object.getPrototypeOf,dd=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var n in e)fo(t,n,{get:e[n],enumerable:!0})},Bi=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ud(e))!dd.call(t,s)&&s!==n&&fo(t,s,{get:()=>e[s],enumerable:!(o=cd(e,s))||o.enumerable});return t};var E=(t,e,n)=>(n=t!=null?ld(pd(t)):{},Bi(e||!t||!t.__esModule?fo(n,"default",{value:t,enumerable:!0}):n,t)),md=t=>Bi(fo({},"__esModule",{value:!0}),t);var vf={};j(vf,{Card:()=>F,Chip:()=>ea,ContentEditableInput:()=>Mt,DeepdeskAPI:()=>et,DeepdeskSDK:()=>mo,InputMediator:()=>Ne,InputType:()=>rt,KeyboardHint:()=>No,Label:()=>Do,Locale:()=>En,Section:()=>ot,SectionList:()=>Ho,Sources:()=>st,Suggestion:()=>N,SuggestionList:()=>Re,TextAreaInput:()=>De,ToggleButton:()=>wt,attachFile:()=>Zp,authenticateWithKey:()=>Xp,createOverlayContainer:()=>Xt,createRangeFromOffsets:()=>At,escapeHTML:()=>pn,fetchPlatformConfig:()=>Qp,formatTextMarkup:()=>$p,getRangeOffsets:()=>$s,getRangeText:()=>co,isSupportedInputElement:()=>Ys,updateContentEditable:()=>Gp,updateTextArea:()=>Wp,useStyles:()=>y,waitForElementVisibilityChange:()=>er});module.exports=md(vf);var yo=E(require("classnames")),ue=E(require("react"));var ho=E(require("react")),Ki=E(require("classnames")),vn=ho.default.createContext({});function y(t,e){let o=(0,ho.useContext)(vn)[t];return o?Object.entries(e).reduce((s,[r,i])=>{let a=o[r];return{...s,[r]:(0,Ki.default)(i,a)}},{}):e}var Ui={root:"_root_vr71j_1"};var xt=require("react/jsx-runtime"),Vi=()=>(0,xt.jsxs)("svg",{className:Ui.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,xt.jsx)("defs",{children:(0,xt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,xt.jsx)("title",{children:"Failed loading image"}),(0,xt.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 sr={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 Ct=require("react/jsx-runtime"),So=(0,ue.createContext)(sr),gd=({title:t,src:e})=>{let n=(0,ue.useContext)(So),[o,s]=(0,ue.useState)(!1);return(0,ue.useEffect)(()=>{s(!1)},[e]),(0,Ct.jsx)("div",{className:n.imageWrapper,children:e&&!o?(0,Ct.jsx)("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):(0,Ct.jsx)(Vi,{})})},fd=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=(0,ue.useContext)(So);return(0,Ct.jsx)("div",{className:(0,yo.default)(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},hd=({as:t="h1",cropText:e=!1,className:n,children:o})=>{let s=(0,ue.useContext)(So);return ue.default.createElement(t,{className:(0,yo.default)(s.title,n,{[s.contentIsCropped]:e})},o)},vo=({children:t})=>{let e=y("Card",sr);return(0,Ct.jsx)("div",{className:(0,yo.default)(e.root),children:(0,Ct.jsx)(So.Provider,{value:e,children:t})})};vo.Image=gd;vo.Content=fd;vo.Title=hd;var F=vo;var ji={root:"_root_nkim0_1"};var Mo=require("react");var rr=function(t,e){return rr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},rr(t,e)};function xn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");rr(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var oe=function(){return oe=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oe.apply(this,arguments)};function zi(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function xo(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}var Co;(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"})(Co||(Co={}));var To=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Te;(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"})(Te||(Te={}));var wo;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(wo||(wo={}));function ir(t){return t.type===Te.literal}function qi(t){return t.type===Te.argument}function bo(t){return t.type===Te.number}function Eo(t){return t.type===Te.date}function _o(t){return t.type===Te.time}function Po(t){return t.type===Te.select}function ko(t){return t.type===Te.plural}function Wi(t){return t.type===Te.pound}function Ro(t){return t.type===Te.tag}function Io(t){return!!(t&&typeof t=="object"&&t.type===wo.number)}function Cn(t){return!!(t&&typeof t=="object"&&t.type===wo.dateTime)}function ar(t){t.forEach(function(e){if(delete e.location,Po(e)||ko(e))for(var n in e.options)delete e.options[n].location,ar(e.options[n].value);else bo(e)&&Io(e.style)||(Eo(e)||_o(e))&&Cn(e.style)?delete e.style.location:Ro(e)&&ar(e.children)})}function Gi(t,e){e===void 0&&(e={}),e=oe({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new To(t,e).parse();if(n.err){var o=SyntaxError(Co[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||ar(n.val),n.val}function Lo(t,e){var n=e&&e.cache?e.cache:Td,o=e&&e.serializer?e.serializer:Cd,s=e&&e.strategy?e.strategy:Sd;return s(t,{cache:n,serializer:o})}function yd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function $i(t,e,n,o){var s=yd(o)?o:n(o),r=e.get(s);return typeof r>"u"&&(r=t.call(this,o),e.set(s,r)),r}function Xi(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,o),e.set(s,r)),r}function lr(t,e,n,o,s){return n.bind(e,t,o,s)}function Sd(t,e){var n=t.length===1?$i:Xi;return lr(t,this,n,e.cache.create(),e.serializer)}function vd(t,e){return lr(t,this,Xi,e.cache.create(),e.serializer)}function xd(t,e){return lr(t,this,$i,e.cache.create(),e.serializer)}var Cd=function(){return JSON.stringify(arguments)};function cr(){this.cache=Object.create(null)}cr.prototype.get=function(t){return this.cache[t]};cr.prototype.set=function(t,e){this.cache[t]=e};var Td={create:function(){return new cr}},Ao={variadic:vd,monadic:xd};var Tt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Tt||(Tt={}));var Tn=function(t){xn(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var ur=function(t){xn(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Tt.INVALID_VALUE,r)||this}return e}(Tn);var Qi=function(t){xn(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),Tt.INVALID_VALUE,s)||this}return e}(Tn);var Zi=function(t){xn(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),Tt.MISSING_VALUE,o)||this}return e}(Tn);var q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(q||(q={}));function wd(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==q.literal||n.type!==q.literal?e.push(n):o.value+=n.value,e},[])}function bd(t){return typeof t=="function"}function wn(t,e,n,o,s,r,i){if(t.length===1&&ir(t[0]))return[{type:q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var u=c[l];if(ir(u)){a.push({type:q.literal,value:u.value});continue}if(Wi(u)){typeof r=="number"&&a.push({type:q.literal,value:n.getNumberFormat(e).format(r)});continue}var d=u.value;if(!(s&&d in s))throw new Zi(d,i);var p=s[d];if(qi(u)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?q.literal:q.object,value:p});continue}if(Eo(u)){var g=typeof u.style=="string"?o.date[u.style]:Cn(u.style)?u.style.parsedOptions:void 0;a.push({type:q.literal,value:n.getDateTimeFormat(e,g).format(p)});continue}if(_o(u)){var g=typeof u.style=="string"?o.time[u.style]:Cn(u.style)?u.style.parsedOptions:o.time.medium;a.push({type:q.literal,value:n.getDateTimeFormat(e,g).format(p)});continue}if(bo(u)){var g=typeof u.style=="string"?o.number[u.style]:Io(u.style)?u.style.parsedOptions:void 0;g&&g.scale&&(p=p*(g.scale||1)),a.push({type:q.literal,value:n.getNumberFormat(e,g).format(p)});continue}if(Ro(u)){var h=u.children,m=u.value,x=s[m];if(!bd(x))throw new Qi(m,"function",i);var b=wn(h,e,n,o,s,r),f=x(b.map(function(k){return k.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(k){return{type:typeof k=="string"?q.literal:q.object,value:k}}))}if(Po(u)){var v=u.options[p]||u.options.other;if(!v)throw new ur(u.value,p,Object.keys(u.options),i);a.push.apply(a,wn(v.value,e,n,o,s));continue}if(ko(u)){var v=u.options["=".concat(p)];if(!v){if(!Intl.PluralRules)throw new Tn(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var cd=Object.create;var hn=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var ud=Object.getOwnPropertyNames;var dd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var o in e)hn(t,o,{get:e[o],enumerable:!0})},Fi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ud(e))!md.call(t,s)&&s!==o&&hn(t,s,{get:()=>e[s],enumerable:!(n=pd(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?cd(dd(t)):{},Fi(e||!t||!t.__esModule?hn(o,"default",{value:t,enumerable:!0}):o,t)),gd=t=>Fi(hn({},"__esModule",{value:!0}),t);var _f={};j(_f,{Card:()=>H,Chip:()=>ea,ContentEditableInput:()=>Mt,DeepdeskAPI:()=>et,DeepdeskSDK:()=>gn,InputMediator:()=>Ne,InputType:()=>rt,KeyboardHint:()=>Dn,Label:()=>Bn,Locale:()=>ko,Section:()=>nt,SectionList:()=>Hn,Sources:()=>st,Suggestion:()=>N,SuggestionList:()=>Ie,TextAreaInput:()=>De,ToggleButton:()=>wt,attachFile:()=>Ju,authenticateWithKey:()=>Qu,createOverlayContainer:()=>Xt,createRangeFromOffsets:()=>At,escapeHTML:()=>mo,fetchPlatformConfig:()=>Zu,formatTextMarkup:()=>Xu,getRangeOffsets:()=>$s,getRangeText:()=>un,isSupportedInputElement:()=>Ys,updateContentEditable:()=>$u,updateTextArea:()=>Gu,useStyles:()=>y,waitForElementVisibilityChange:()=>er});module.exports=gd(_f);var Sn=T(require("classnames")),ue=T(require("react"));var yn=T(require("react")),Ki=T(require("classnames")),xo=yn.default.createContext({});function y(t,e){let{debug:o,...n}=(0,yn.useContext)(xo),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Ki.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var Ui={root:"_root_vr71j_1"};var xt=require("react/jsx-runtime"),zi=()=>(0,xt.jsxs)("svg",{className:Ui.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,xt.jsx)("defs",{children:(0,xt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,xt.jsx)("title",{children:"Failed loading image"}),(0,xt.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 sr={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 bt=require("react/jsx-runtime"),vn=(0,ue.createContext)(sr),fd=({title:t,src:e})=>{let o=(0,ue.useContext)(vn),[n,s]=(0,ue.useState)(!1);return(0,ue.useEffect)(()=>{s(!1)},[e]),(0,bt.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,bt.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,bt.jsx)(zi,{})})},hd=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,ue.useContext)(vn);return(0,bt.jsx)("div",{className:(0,Sn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},yd=({as:t="h1",cropText:e=!1,className:o,children:n})=>{let s=(0,ue.useContext)(vn);return ue.default.createElement(t,{className:(0,Sn.default)(s.title,o,{[s.contentIsCropped]:e})},n)},_n=({children:t})=>{let e=y("Card",sr);return(0,bt.jsx)("div",{className:(0,Sn.default)(e.root),children:(0,bt.jsx)(vn.Provider,{value:e,children:t})})};_n.Image=fd;_n.Content=hd;_n.Title=yd;var H=_n;var ji={root:"_root_nkim0_1"};var On=require("react");var rr=function(t,e){return rr=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])},rr(t,e)};function bo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");rr(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 xn(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 bn;(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"})(bn||(bn={}));var Cn=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 wn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(wn||(wn={}));function ir(t){return t.type===be.literal}function qi(t){return t.type===be.argument}function Tn(t){return t.type===be.number}function En(t){return t.type===be.date}function kn(t){return t.type===be.time}function Pn(t){return t.type===be.select}function In(t){return t.type===be.plural}function Wi(t){return t.type===be.pound}function Rn(t){return t.type===be.tag}function Ln(t){return!!(t&&typeof t=="object"&&t.type===wn.number)}function Co(t){return!!(t&&typeof t=="object"&&t.type===wn.dateTime)}function ar(t){t.forEach(function(e){if(delete e.location,Pn(e)||In(e))for(var o in e.options)delete e.options[o].location,ar(e.options[o].value);else Tn(e)&&Ln(e.style)||(En(e)||kn(e))&&Co(e.style)?delete e.style.location:Rn(e)&&ar(e.children)})}function Gi(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Cn(t,e).parse();if(o.err){var n=SyntaxError(bn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||ar(o.val),o.val}function An(t,e){var o=e&&e.cache?e.cache:Cd,n=e&&e.serializer?e.serializer:bd,s=e&&e.strategy?e.strategy:vd;return s(t,{cache:o,serializer:n})}function Sd(t){return t==null||typeof t=="number"||typeof t=="boolean"}function $i(t,e,o,n){var s=Sd(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function Xi(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function lr(t,e,o,n,s){return o.bind(e,t,n,s)}function vd(t,e){var o=t.length===1?$i:Xi;return lr(t,this,o,e.cache.create(),e.serializer)}function _d(t,e){return lr(t,this,Xi,e.cache.create(),e.serializer)}function xd(t,e){return lr(t,this,$i,e.cache.create(),e.serializer)}var bd=function(){return JSON.stringify(arguments)};function cr(){this.cache=Object.create(null)}cr.prototype.get=function(t){return this.cache[t]};cr.prototype.set=function(t,e){this.cache[t]=e};var Cd={create:function(){return new cr}},Mn={variadic:_d,monadic:xd};var Ct;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Ct||(Ct={}));var wo=function(t){bo(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 pr=function(t){bo(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('", "'),'"'),Ct.INVALID_VALUE,r)||this}return e}(wo);var Qi=function(t){bo(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Ct.INVALID_VALUE,s)||this}return e}(wo);var Zi=function(t){bo(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,'"'),Ct.MISSING_VALUE,n)||this}return e}(wo);var q;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(q||(q={}));function wd(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==q.literal||o.type!==q.literal?e.push(o):n.value+=o.value,e},[])}function Td(t){return typeof t=="function"}function To(t,e,o,n,s,r,i){if(t.length===1&&ir(t[0]))return[{type:q.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(ir(p)){a.push({type:q.literal,value:p.value});continue}if(Wi(p)){typeof r=="number"&&a.push({type:q.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Zi(d,i);var u=s[d];if(qi(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?q.literal:q.object,value:u});continue}if(En(p)){var g=typeof p.style=="string"?n.date[p.style]:Co(p.style)?p.style.parsedOptions:void 0;a.push({type:q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(kn(p)){var g=typeof p.style=="string"?n.time[p.style]:Co(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:q.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Tn(p)){var g=typeof p.style=="string"?n.number[p.style]:Ln(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:q.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(Rn(p)){var h=p.children,m=p.value,_=s[m];if(!Td(_))throw new Qi(m,"function",i);var w=To(h,e,o,n,s,r),f=_(w.map(function(P){return P.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(P){return{type:typeof P=="string"?q.literal:q.object,value:P}}))}if(Pn(p)){var v=p.options[u]||p.options.other;if(!v)throw new pr(p.value,u,Object.keys(p.options),i);a.push.apply(a,To(v.value,e,o,n,s));continue}if(In(p)){var v=p.options["=".concat(u)];if(!v){if(!Intl.PluralRules)throw new wo(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,Tt.MISSING_INTL_API,i);var C=n.getPluralRules(e,{type:u.pluralType}).select(p-(u.offset||0));v=u.options[C]||u.options.other}if(!v)throw new ur(u.value,p,Object.keys(u.options),i);a.push.apply(a,wn(v.value,e,n,o,s,p-(u.offset||0)));continue}}return wd(a)}function Ed(t,e){return e?oe(oe(oe({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=oe(oe({},t[o]),e[o]||{}),n},{})):t}function _d(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=Ed(t[o],e[o]),n},oe({},t)):t}function pr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function Pd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Lo(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,xo([void 0],n,!1)))},{cache:pr(t.number),strategy:Ao.variadic}),getDateTimeFormat:Lo(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,xo([void 0],n,!1)))},{cache:pr(t.dateTime),strategy:Ao.variadic}),getPluralRules:Lo(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,xo([void 0],n,!1)))},{cache:pr(t.pluralRules),strategy:Ao.variadic})}}var Ji=function(){function t(e,n,o,s){n===void 0&&(n=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var u=r.formatToParts(c);if(u.length===1)return u[0].value;var d=u.reduce(function(p,g){return!p.length||g.type!==q.literal||typeof p[p.length-1]!="string"?p.push(g.value):p[p.length-1]+=g.value,p},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return wn(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=n,this.resolvedLocale=t.resolveLocale(n),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=zi(i,["formatters"]);this.ast=t.__parse(e,oe(oe({},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=_d(t.formats,o),this.formatters=s&&s.formatters||Pd(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(!(typeof Intl.Locale>"u")){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Gi,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t}();function kd(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var Rd="dummy",dr=(0,Mo.createContext)(null);function _(t){let e=(0,Mo.useContext)(dr);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=t[e]??{};return(o,s)=>{let r=kd(n,o);return r?new Ji(r).format(s):(e!==Rd&&console.warn(`${o} does not exist in messages of ${e}`),`[${o}]`)}}var mr={};j(mr,{enUS:()=>Id,nlNL:()=>Ld});var Id={experimental:[{type:0,value:"Experimental"}]},Ld={experimental:[{type:0,value:"Experimenteel"}]};var gr=require("react/jsx-runtime"),Yi=({children:t})=>{let e=y("Chip",ji);return(0,gr.jsx)("span",{className:e.root,children:t})},Oo=()=>{let t=_(mr);return(0,gr.jsx)(Yi,{children:t("experimental")})},ea=Yi;var na=E(require("classnames"));var ta={root:"_root_cq1yq_1"};var oa=require("react/jsx-runtime");var Ad={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Md=({className:t,keyCode:e,...n})=>{let o=y("KeyboardHint",ta);return(0,oa.jsx)("span",{"data-key":Ad[e],className:(0,na.default)(t,o.root),...n})},No=Md;var ra=E(require("classnames"));var sa={root:"_root_4a08n_1"};var ia=require("react/jsx-runtime"),Od=({className:t,children:e,...n})=>{let o=y("Label",sa);return(0,ia.jsx)("span",{...n,className:(0,ra.default)(t,o.root),children:e})},Do=Od;var aa={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Ht=require("react/jsx-runtime"),Nd=({title:t,children:e,type:n,...o})=>{let s=y("Section",aa);return(0,Ht.jsxs)("section",{...o,className:s.root,"data-section-type":n,children:[t&&(0,Ht.jsx)("div",{className:s.subTitleContainer,children:(0,Ht.jsx)("span",{className:s.subtitle,children:t})}),(0,Ht.jsx)("div",{className:s.suggestions,children:e})]})},ot=Nd;var ca=E(require("classnames")),ua=E(require("react"));var la={root:"_root_19wxp_1"};var pa=require("react/jsx-runtime"),Dd=ua.default.forwardRef(({className:t,children:e},n)=>{let o=y("SectionList",la);return(0,pa.jsx)("div",{ref:n,className:(0,ca.default)(o.root,t),children:e})}),Ho=Dd;var bn=E(require("classnames")),de=E(require("react"));var fr={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 pe=require("react/jsx-runtime"),Ft=(0,de.createContext)(fr),Hd=({fixed:t,children:e,...n})=>{let o=(0,de.useContext)(Ft);return(0,pe.jsx)("div",{...n,className:(0,bn.default)(o.actions,{[o.actionsIsFixed]:t}),children:e})},Fd=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=(0,de.useContext)(Ft);return(0,pe.jsxs)("div",{className:(0,bn.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,(0,pe.jsx)("ul",{className:r.dropdownList,children:s})]})},Bd=({index:t,label:e,onClick:n})=>{let o=(0,de.useContext)(Ft);return(0,pe.jsx)("li",{className:o.dropdownItem,children:(0,pe.jsx)("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},Kd=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=(0,de.useContext)(Ft);return(0,pe.jsx)("button",{type:"button",className:(0,bn.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o??(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},hr=({labels:t})=>{let e=(0,de.useContext)(Ft);return(0,pe.jsx)("div",{className:e.labels,children:t.map(n=>(0,pe.jsx)("span",{className:e.label,children:n},n))})},Bt=de.default.forwardRef(({className:t,selected:e,onClick:n,children:o,as:s="div",...r},i)=>{let a=y("Suggestion",fr),l=(0,de.useCallback)(c=>{c.preventDefault(),n&&n(c)},[n]);return(0,pe.jsx)(s,{...r,ref:i,className:(0,bn.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!n}),onClick:l,children:(0,pe.jsx)(Ft.Provider,{value:a,children:o})})});Bt.Labels=hr;Bt.Actions=Hd;Bt.ActionButton=Kd;Bt.DropdownButton=Fd;Bt.DropdownItem=Bd;var N=Bt;var ma=E(require("classnames"));var da={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var ga=require("react/jsx-runtime"),Ud=({withDivider:t,children:e})=>{let n=y("SuggestionList",da);return(0,ga.jsx)("div",{className:(0,ma.default)(n.root,{[n.isWithDivider]:t}),children:e})},Re=Ud;var ha=E(require("classnames"));var fa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Fo=require("react/jsx-runtime"),Vd=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=y("ToggleButton",fa);return(0,Fo.jsx)("button",{type:"button",className:(0,ha.default)(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:(0,Fo.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Fo.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},wt=Vd;var ya=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Kt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Sa=/x-deepdesk-(([a-z0-9\-_])+-version)/,st=(p=>(p.SEARCH="search",p.TEMPLATE="template",p.ELASTIC_SEARCH="studio-search",p.GPT="gpt",p.TRIE="trie",p.TRIE_WITH_TYPOS="trie-with-typos",p.SEMANTIC="semantic",p.TEXT_RECOMMENDATION="text_recommendation",p.URL_RECOMMENDATION="url_recommendation",p.LINK_RECOMMENDATION="link_recommendation",p.PERSONAL_COLLECTION="personal-collection",p.PERSONAL_COLLECTION_SEARCH="personal-collection-search",p))(st||{}),rt=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(rt||{});var tt=require("react-dom");var Vc=require("react");var va=require("@reduxjs/toolkit"),xa=require("react-redux");var En=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(En||{});var jd={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"},Ca=(0,va.createSlice)({name:"settings",initialState:jd,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s>"u"||(t[o]=s)})}}}),{set:_n}=Ca.actions,yr=t=>e=>e.settings[t],T=t=>(0,xa.useSelector)(yr(t)),Ta=Ca.reducer;var cc=require("react"),rn=require("react-redux");var Ie=require("@reduxjs/toolkit"),Pa=require("diff"),ka=require("react-redux");function wa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function it(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>it(r,e[i],n-1)):wa(t)&&wa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>it(t[i],e[i],n-1)):!1}function zd(t){return Math.max(...t.map(e=>e.length))}function qd(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return{...o,[s]:r}}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function ba(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<zd(o);s++){let r=qd(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Wd=2;function Sr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=ba(t,Wd);return n&&n.text!==e?n:t[0]}var we=require("@reduxjs/toolkit"),Ea={current:null,isSupported:null},L=(0,we.createAction)("resetConversation"),Bo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Ko=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Uo=t=>t.conversation.isSupported,vr=(0,we.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.sessionId,t.options)}),Vo=(0,we.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),jo=(0,we.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationBySessionId(t.sessionId,t.options)}),zo=(0,we.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Ko(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),xr=(0,we.createAsyncThunk)("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationBySessionId(t.sessionId).catch(()=>null).then(o=>{if(!o)return n.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return n.updateConversation(o.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),qo=(0,we.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Ko(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(s=>({...s})))}),Gd=[Vo.rejected,jo.rejected,zo.rejected,qo.rejected].map(t=>t==null?void 0:t.toString()),$d=(0,we.createSlice)({name:"conversation",initialState:Ea,reducers:{},extraReducers:t=>{t.addCase(vr.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Vo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(jo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(xr.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(zo.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(qo.fulfilled,(e,n)=>{e.current&&(e.current.messages=n.payload)}).addCase(L,()=>Ea).addMatcher(e=>Gd.includes(e.type),(e,n)=>{throw new Error(n.error.message)})}}),_a=$d.reducer;var at={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Go(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var $o=(0,Ie.createAction)("input/replaceText"),Xo=(0,Ie.createAction)("input/keyDown"),Pn=(0,Ie.createAction)("input/sendMessage"),Qo=(0,Ie.createAction)("input/sendEditSuggestionMessage"),Zo=(0,Ie.createAction)("input/uiInputChange"),Jo=(0,Ie.createAction)("input/applyImageSuggestion"),se=(0,Ie.createAction)("input/sendEvent");function Wo(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:n,abVariant:o,abTestName:s,trainingJobs:r,sourceText:i},eventMetrics:{inputType:a},replace:l}=t.stagedSuggestion,c=n==="search"||n==="personal-collection-search",u=c||l==="selection"?e:e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions=[...t.metrics.textSuggestions,{text:u,source:n,abVariant:o,abTestName:s,inputType:a,sourceText:i,trainingJobs:r||[],searchTerm:c?t.userCommitted.text:null}],t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Ra=t=>(0,Ie.createSlice)({name:t,initialState:at,reducers:{initialInput(e,n){let{text:o,selection:s,html:r}=n.payload;e.text=o,e.selection.start=(s==null?void 0:s.start)??o.length,e.selection.end=(s==null?void 0:s.end)??o.length,e.userCommitted.text=o,e.userCommitted.selection.start=(s==null?void 0:s.start)??o.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??o.length,e.html=r||null},reset(e){Object.assign(e,{...at,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Sr(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,n){e.html=n.payload},changeSelection(e,n){n.payload&&(it(e.selection,n.payload)||(e.selection=n.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Wo(e)))},userInput(e,n){var i,a,l,c;if(e.previousKeyDownEvent){let{key:u,shiftKey:d,ctrlKey:p,metaKey:g,altKey:h}=e.previousKeyDownEvent;switch(u){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:x}=n.payload,b=(0,Pa.diffChars)(m,x);m.length-x.length>1&&e.metrics.deletions.push(...b.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=m.length-x.length;break}case"C":case"V":case"X":if(!p&&!g){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!p&&!g&&!h){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&n.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),n.payload.text===""&&(e.metrics=at.metrics,e.textSuggestions=[]),e.text!==n.payload.text&&Wo(e);let{text:o,html:s,selection:r}=n.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=o,e.html=s||null,e.userCommitted.text=o,e.previousKeyDownEvent=null},stageSuggestion(e,n){let{text:o}=n.payload;switch(e.stagedSuggestion=n.payload,e.tabCompletionSuggestion=void 0,n.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${o}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+o.length,e.selection.start+=o.length;break;case"until-selection-end":e.text=`${o}${e.text.slice(e.selection.end)}`,e.selection.start=o.length,e.selection.end=o.length;break;default:throw new Error(`Unknown replace ${n.payload.replace}`)}n.payload.eventMetrics.inputType==="tab"&&Wo(e)},commitSuggestion(e){Wo(e)},offeredTextSuggestion(e,n){let{text:o,suggestion:{source:s}}=n.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===o)||e.metrics.offeredTextSuggestions.push({text:o,source:s})},registerCut(e,n){let{metrics:o}=e,s=n.payload;e.metrics={...e.metrics,numCharsCut:o.numCharsCut+s.length,cuts:[...o.cuts,s]}},registerPaste(e,n){let{metrics:o}=e,{text:s,selectionText:r}=n.payload,i=o.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...o.deletions,r]:o.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:o.numCharsPasted+s.length,numPaste:o.numPaste+1,pastes:[...o.pastes,s]}},registerKeyDown(e,n){e.previousKeyDownEvent=n.payload},nextTextSuggestionIndex(e){let n=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<n-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,n){if(e.selectedSuggestionIndex=-1,e.textSuggestions=n.payload,n.payload.length===0)return;let o=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=Sr(n.payload,o);e.tabCompletionSuggestion=s!=null&&s.text.includes(o)?s:void 0},setSelectedTextSuggestionIndex(e,n){e.selectedSuggestionIndex=n.payload},mergeMetrics(e,{payload:n}){e.metrics.numCharsTyped+=n.numCharsTyped,e.metrics.numCharsPasted+=n.numCharsPasted,e.metrics.numCharsCut+=n.numCharsCut,e.metrics.numCharsDeleted+=n.numCharsDeleted,e.metrics.numPaste+=n.numPaste,e.metrics.pastes.push(...n.pastes),e.metrics.deletions.push(...n.deletions)}},extraReducers:e=>{e.addCase(L,n=>{n.tabCompletionSuggestion=at.tabCompletionSuggestion,n.previousKeyDownEvent=at.previousKeyDownEvent,n.textSuggestions=at.textSuggestions,n.selectedSuggestionIndex=at.selectedSuggestionIndex,n.metrics=at.metrics})}}),Cr=Ra("input"),Ut=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Xd=t=>t.input.selection,Ia=()=>(0,ka.useSelector)(Xd),{userInput:La,changeSelection:Tr,initialInput:Aa,mergeMetrics:Ma,nextTextSuggestionIndex:Oa,offeredTextSuggestion:Na,previousTextSuggestionIndex:Da,registerCut:Ha,registerKeyDown:Fa,registerPaste:Ba,reset:Ka,resetToCommitted:kn,setInputHtml:Ua,setSelectedTextSuggestionIndex:Yo,setTextSuggestions:lt,stageSuggestion:be,commitSuggestion:ct}=Cr.actions,Z=Ra("overlay");var Vt=require("react");var Va={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var wr=require("react/jsx-runtime"),Qd=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,Vt.useRef)(null),l=(0,Vt.useRef)(null),c=y("Dialog",Va);return(0,Vt.useEffect)(()=>{var p,g;let u=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},d=h=>{let m=window.getSelection();m!=null&&m.toString()||h.target===a.current&&t&&o()};return(p=a.current)==null||p.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",u),()=>{var h,m;(h=a.current)==null||h.removeEventListener("click",d),(m=a.current)==null||m.removeEventListener("keyup",u)}},[a,l,s,o]),(0,Vt.useEffect)(()=>{var u,d;!a.current||!t||!e||(d=(u=a.current)==null?void 0:u.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?(0,wr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,wr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:n})}):null},jt=Qd;var Kr=require("react"),ms=require("react-redux");var br={};j(br,{enUS:()=>Zd,nlNL:()=>Jd});var Zd={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?"}]},Jd={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ja={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var Rn=require("react/jsx-runtime"),es=()=>(0,Rn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Rn.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Rn.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 In=require("react/jsx-runtime"),za=()=>(0,In.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,In.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,In.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 ge=require("react"),il=require("react-redux"),al=require("interweave"),Ar=E(require("classnames"));var Er={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var Wa=require("interweave"),Ga=E(require("classnames"));var zt=require("react");function qa(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function ts(t){let e=(0,zt.useRef)(null),[n,o]=(0,zt.useState)(!1);return(0,zt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=qa((u,d)=>{let p=e.current;if(!p)return;let g=u/r,h=d/r,m=p.getBoundingClientRect(),x=g>m.x&&g<m.x+m.width&&h>m.y&&h<m.y+m.height;x&&!s?(s=!0,o(!0)):!x&&s&&(s=!1,o(!1))},({clientX:u,clientY:d})=>[u,d]),[l,c]=qa(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,n]}var me={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var _r=require("react/jsx-runtime"),Yd=({inputElement:t,children:e})=>{let n=y("TabCompletion",me),[o,s]=ts(t);return(0,_r.jsx)("mark",{ref:o,className:(0,Ga.default)(n.matchPlaceholder,{[n.hover]:s}),children:e})},qt=class extends Wa.Matcher{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return(0,_r.jsx)(Yd,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Wt=require("react");function ns(t){return t.contentEditable==="true"}function em(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function $a(t){let{selectionStart:e,selectionEnd:n}=ns(t)?em(t):t;return[e,n]}function os(t){let[,e]=(0,Wt.useState)(),n=(0,Wt.useRef)(null);return n.current=$a(t),(0,Wt.useEffect)(()=>{let o=()=>{let[s,r]=n.current??[],i=$a(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function ss(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(Kt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=o.indexOf(l,a);return s>c&&r<c+l.length?(n.selectionStart=c,n.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var Xa=require("react");function Gt(t){(0,Xa.useEffect)(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function bt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Qa,Le=new Map,tm=["bottom","height","left","right","top","width"],nm=(t={},e={})=>tm.some(n=>t[n]!==e[n]),Za=()=>{let t=[];Le.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),Le.delete(n);return}let o=n.getBoundingClientRect();nm(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(n=>n(e.rect))}),Le.size!==0&&(Qa=window.requestAnimationFrame(Za))};function Ja(t,e){return{observe(){let n=Le.size===0;if(Le.has(t)){let o=Le.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else Le.set(t,{rect:void 0,callbacks:[e]});n&&Za()},unobserve(){let n=Le.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Le.delete(t),Le.size||cancelAnimationFrame(Qa)}}}}var Ya,Ae=new Map,el=()=>{Ae.forEach((t,e)=>{if(!e.isConnected){Ae.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),Ae.size!==0&&(Ya=window.requestAnimationFrame(el))};function tl(t,e){return{observe(){let n=Ae.size===0;Ae.has(t)?Ae.get(t).callbacks.push(e):Ae.set(t,{visible:void 0,callbacks:[e]}),n&&el()},unobserve(){let n=Ae.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||Ae.delete(t),Ae.size||cancelAnimationFrame(Ya)}}}}var Pr=["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 kr(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function $t(t){return parseFloat(t)}function rs(t){return Math.round(t*1e6)}function nl(t){return t/1e6}function Rr(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=$t(t.width),r=$t(t.borderLeftWidth),i=$t(t.borderRightWidth),a=$t(t.paddingRight),l=nl(rs(s)-rs(r)-rs(i)),c=nl(rs(o));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function Xt(t,e={}){var l;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position="fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",bt(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};kr(o,n,Pr),Rr(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=tl(t,()=>{kr(o,n,Pr),Rr(o,t,n),r(),setTimeout(r,0)}),a=Ja(t,c=>{if(c===null){e.onRemove&&e.onRemove(),n.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),n.style.display="none",s=!0;return}if(kr(o,n,Pr),Rr(o,t,n),r(),n.style.top=`${c.top}px`,n.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let u=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),p=$t(d.borderTopWidth),g=$t(d.borderBottomWidth),h=u.top+p-c.top,m=c.top+c.height+-(u.top+u.height-g);n.style.clipPath=`inset(${h}px 0px ${m}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(l=t.parentElement)==null||l.appendChild(n),a.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Ir={};j(Ir,{enUS:()=>om,nlNL:()=>sm});var om={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"}]},sm={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 Ln=require("react/jsx-runtime"),ol=()=>(0,Ln.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Ln.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Ln.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 Lr=require("react/jsx-runtime"),sl=()=>(0,Lr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Lr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var rl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(rl||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}triggerChange(){let e=this.getText(),n=this.getHTML(),o=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&o&&!this.isSubmitting&&this.emit("change",{plainText:e,rawHtml:n}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&o)&&(this.emit("updated",{plainText:e,rawHtml:n}),this.currentHTML=n))}handleKeyUp(e){let{key:n,shiftKey:o}=e;(n==="Enter"&&o===!0||n==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(rl).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleCut(){let e=this.currentSelection;this.isPossibleClearInputAction=!0,e&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){let n=(e.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){let e=()=>{let o=document.activeElement===this.element?this.getSelection():null;it(this.currentSelection,o)||(this.currentSelection=o,this.emit("selection",o))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),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 n=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});n.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{n.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}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 De=class extends Ne{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:n}=this.element;return{start:e,end:n}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),o=e(this.element);Promise.resolve(o).then(()=>{this.currentText=this.getText(),n!==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 n=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};var J=require("react/jsx-runtime"),rm=({value:t,onUse:e,...n})=>{var u;let o=_(Ir),s=(0,il.useDispatch)(),r=y("EditSuggestionTextInput",Er),[i,a]=(0,ge.useState)(null),l=(0,ge.useRef)(null),c=((u=t.match(Kt))==null?void 0:u.length)||0;return(0,ge.useEffect)(()=>{let d;return l.current&&(a(l.current),d=new De(l.current),d.on("change",({plainText:p})=>{s(Z.actions.userInput({text:p,selection:d.getSelection()}))}),d.on("keydown",p=>{s(Z.actions.registerKeyDown(Go(p))),p.code==="Enter"&&p.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:p,selectionText:g})=>{s(Z.actions.registerPaste({text:p,selectionText:g}))}),d.on("cut",({selectionText:p})=>{s(Z.actions.registerCut(p))})),()=>{s(Z.actions.reset()),d.dispose(),d.deactivate()}},[l]),(0,ge.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,ge.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let d=l.current.value.length;l.current.setSelectionRange(d,d),l.current.focus()},0)},[l]),(0,J.jsxs)("div",{className:r.textInputWrapper,children:[(0,J.jsx)("textarea",{...n,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,J.jsx)(im,{inputElement:l.current,value:t}),(0,J.jsxs)("div",{className:(0,Ar.default)(r.alert,c===0?r.success:r.warning),children:[(0,J.jsx)("div",{className:r.alertText,children:o("placeholders",{placeholderSize:c})}),c===0?(0,J.jsx)(ol,{}):(0,J.jsx)(sl,{})]})]})},im=({inputElement:t,value:e})=>{let n=y("EditSuggestionTextInput",Er),o=(0,ge.useRef)(null),s=os(t);return(0,ge.useEffect)(()=>{ss(t,s)},[s,t]),(0,J.jsx)(am,{inputElement:t,children:(0,J.jsxs)("div",{ref:o,className:(0,Ar.default)(n.root,n.agentText),children:[(0,J.jsx)(al.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new qt("placeholders")],inputElement:t,boundaryRef:o}),(0,J.jsx)("br",{})]})})},am=({inputElement:t,children:e})=>{let n=(0,ge.useRef)(null);return(0,ge.useEffect)(()=>{if(!n.current)return()=>{};let[o,s]=Xt(t,{overlayContainer:n.current,mirrorOverflow:!0});return()=>{s()}},[n.current]),(0,J.jsx)("div",{ref:n,children:e})},ll=rm;var Yt=require("react");var Y={root:"_root_m5usm_1",list:"_list_m5usm_2",listWrapper:"_listWrapper_m5usm_6",listHorizontal:"_listHorizontal_m5usm_10",page:"_page_m5usm_19",search:"_search_m5usm_25",pageNav:"_pageNav_m5usm_33",pageTitle:"_pageTitle_m5usm_41",pageBackButton:"_pageBackButton_m5usm_48",listHeading:"_listHeading_m5usm_62",listItem:"_listItem_m5usm_70",listItemContent:"_listItemContent_m5usm_79",listItemText:"_listItemText_m5usm_97",listItemDescription:"_listItemDescription_m5usm_105",truncate:"_truncate_m5usm_112",lineClamp:"_lineClamp_m5usm_118",listItemTitle:"_listItemTitle_m5usm_125",listItemAction:"_listItemAction_m5usm_132",listItemPrimaryAction:"_listItemPrimaryAction_m5usm_146",listItemSelected:"_listItemSelected_m5usm_151",sources:"_sources_m5usm_155",sourcesTitle:"_sourcesTitle_m5usm_162",source:"_source_m5usm_155",icon:"_icon_m5usm_177",searchIcon:"_searchIcon_m5usm_194",searchInputWrapper:"_searchInputWrapper_m5usm_199",searchInput:"_searchInput_m5usm_199",select:"_select_m5usm_220",selectType:"_selectType_m5usm_237",selectWrapper:"_selectWrapper_m5usm_241",image:"_image_m5usm_271",imageSrc:"_imageSrc_m5usm_278",imageTitle:"_imageTitle_m5usm_289",actions:"_actions_m5usm_294",actionsWrapper:"_actionsWrapper_m5usm_298",actionsBar:"_actionsBar_m5usm_304",actionButton:"_actionButton_m5usm_313",actionShortcut:"_actionShortcut_m5usm_331",actionShortcutFixKerning:"_actionShortcutFixKerning_m5usm_338"};var An=require("react/jsx-runtime"),lm=({src:t,title:e})=>{let n=y("CommandPalette",Y);return(0,An.jsxs)("div",{className:n.image,children:[(0,An.jsx)("img",{src:t,alt:e,className:n.imageSrc}),e&&(0,An.jsx)("span",{className:n.imageTitle,children:e})]})},cl=lm;var ul=E(require("react")),pl=E(require("classnames"));var Mn=require("react/jsx-runtime");function Mr({children:t,heading:e,orientation:n}){let o=y("CommandPalette",Y);return ul.default.Children.count(t)===0?null:(0,Mn.jsxs)("div",{"data-testid":"commandpalette-list",className:o.list,children:[e&&(0,Mn.jsx)("h4",{className:o.listHeading,children:e}),(0,Mn.jsx)("div",{className:(0,pl.default)(o.listWrapper,n==="horizontal"&&o.listHorizontal),children:t})]})}var On=E(require("classnames"));var is=E(require("react")),gl=require("react/jsx-runtime"),dl=is.default.createContext(void 0);function ut(){let t=is.default.useContext(dl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ml=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=is.default.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return(0,gl.jsx)(dl.Provider,{value:i,children:t})};var fe=require("react/jsx-runtime");function Or({closeOnSelect:t=!0,lineClamp:e,children:n,onClick:o,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...u}){let{selected:d,onChangeOpen:p}=ut(),g=y("CommandPalette",Y);function h(m){o(m),t&&p(!1)}return(0,fe.jsxs)("div",{className:(0,On.default)(g.listItem,d===r&&g.listItemSelected),children:[(0,fe.jsxs)("button",{type:"button",className:(0,On.default)("command-palette-list-item",g.listItemAction,g.listItemPrimaryAction),"aria-disabled":u.disabled??!1,onClick:h,...u,children:[(0,fe.jsxs)("div",{className:g.listItemContent,children:[typeof n=="string"?(0,fe.jsx)("p",{className:(0,On.default)(g.listItemText,g.truncate,c==null?void 0:c.title),children:n}):n,a&&(0,fe.jsx)("p",{className:(0,On.default)(g.listItemDescription,c==null?void 0:c.description,e?g.lineClamp:g.truncate),children:a})]}),i&&(0,fe.jsx)(Oo,{})]}),l&&(0,fe.jsxs)("div",{className:g.sources,children:[(0,fe.jsx)("span",{className:g.sourcesTitle,children:"Sources"}),l.map(m=>m.url?(0,fe.jsx)("a",{className:g.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>s&&s(m),children:m.name},m.url):(0,fe.jsx)("span",{className:g.source,children:m.name},m.name))]})]})}var Nn={};j(Nn,{enUS:()=>cm,nlNL:()=>um});var cm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}]},um={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}]};var pt=require("react/jsx-runtime");function Nr({children:t,title:e,id:n,onDismiss:o,isExperimental:s}){let r=_(Nn),i=y("CommandPalette",Y),{page:a}=ut();return a!==n?null:(0,pt.jsxs)("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[o&&(0,pt.jsxs)("div",{className:i.pageNav,children:[(0,pt.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:o,children:[(0,pt.jsx)(es,{}),r("back")]}),e&&(0,pt.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,pt.jsx)(Oo,{})]}),t]})}var dt=require("react");var as=()=>/Mac/i.test(navigator.platform);var cs=require("@reduxjs/toolkit");var pm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},P=pm;var Qt=require("@reduxjs/toolkit");function dm(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,n)=>({...e,[dm(n)]:O(t[n])}),{}):t}function Dr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function U(t){return Array.isArray(t)?t.map(U):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>({...e,[Dr(n)]:U(t[n])}),{}):t}var mm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Hn=t=>{var e,n,o;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=t.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((o=t.info.visitorInfo)==null?void 0:o.visitorName)||""}},Dn=(0,Qt.createAsyncThunk)("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:n}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let o=await n.client.get("/apis/admin/session/me/",{version:null}),s={};return o.external_id||(s.external_id=t.agentId),o.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?O(o):(await n.client.patch("/apis/admin/session/me/",s,{version:null}),O(o))}),Hr=(0,Qt.createAsyncThunk)("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:n}=e.extra,o=await n.client.get("/apis/admin/session/me/",{version:null}),s={...typeof o.ui_config=="object"?o.ui_config:{},...t};return await n.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),Fr=(0,Qt.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:n}=e.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),fl=t=>t.info.agentInfo,hl=(0,Qt.createSlice)({name:"info",initialState:mm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Dn.pending,(e,n)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...n.meta.arg}}).addCase(Dn.rejected,e=>{e.fetchState="error"}).addCase(Dn.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...n.meta.arg,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""}}).addCase(Hr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Fr.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(L,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:yl}=hl.actions,Sl=hl.reducer;var ls={list:[],fetchState:"idle",isOpen:!1,page:"search"},vl=t=>t.search.isOpen,xl=t=>t.search.page,Cl=t=>t.search.list;function Tl(t,e=n=>n){return n=>n.search.list.filter(o=>o.type===t).map(e)}var Et=(0,cs.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(i=o.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 n.search({profile:s,query:t.query,filters:{type:t.type},params:Hn(o),tags:t.tags});return r}),wl=(0,cs.createSlice)({name:"search",initialState:ls,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ls.fetchState,t.list=ls.list}},extraReducers:t=>{t.addCase(Et.pending,e=>{e.fetchState="loading"}).addCase(Et.rejected,(e,n)=>{e.fetchState="error",P.error(n.error)}).addCase(Et.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload}).addCase(L,()=>ls)}}),{resetSearch:us,setIsOpen:re,setPage:$}=wl.actions,bl=wl.reducer;var gm=/(https?:\/\/[^\s]+)/,ps=t=>t.split(" ").find(e=>gm.test(e));var Br=E(require("classnames"));var ds=require("react/jsx-runtime"),fm=({onClick:t,shortKeys:e,children:n,...o})=>{let s=y("CommandPalette",Y);return(0,ds.jsxs)("button",{type:"button",...o,onClick:t,className:(0,Br.default)(s.actionButton,o.className),children:[n,e&&e.map(r=>(0,ds.jsx)("span",{className:(0,Br.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Zt=fm;var He=require("react/jsx-runtime"),hm=({children:t,primaryLabel:e,secondaryLabel:n,onPrimary:o,onSecondary:s,list:r})=>{let i=y("CommandPalette",Y),a=_(Nn),{selected:l,setSelected:c}=ut(),u=r[l],d=u&&typeof u.text=="string"&&ps(u.text),p=(0,dt.useRef)(null);function g(v){if(!p.current)return;let C=p.current.querySelectorAll(".command-palette-list-item"),k=0,w=0;v==="down"?(C.forEach((ne,B)=>{B===l&&(k=B)}),w=k===C.length-1?0:k+1):v==="up"?(C.forEach((ne,B)=>{B===l&&(k=B)}),w=k?k-1:C.length-1):c(0);let D=C[w];D&&typeof w=="number"&&(c(w),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:w?"center":"end"}))}function h(){if(!p.current)return;let v=p.current.querySelectorAll(".command-palette-list-item"),C=0;v.forEach((w,D)=>{D===l&&(C=D)});let k=v[C];k&&k.click()}let m=()=>{d&&window.open(d,"_blank")},x=()=>{u&&o(u,l)},b=()=>{!u.type||["IMAGE","command"].includes(u.type)||s&&s(u,l)},f=(0,dt.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&d){m();return}if(v.key==="Enter"&&v.shiftKey){b();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),g("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),g("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return(0,dt.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,He.jsxs)("div",{className:i.actions,children:[(0,He.jsx)("div",{className:i.actionsWrapper,ref:p,children:t}),(0,He.jsxs)("div",{className:i.actionsBar,children:[d&&(0,He.jsx)(Zt,{onClick:m,shortKeys:[as()?8997:"ALT",8629],children:a("visitUrl")}),u&&(0,He.jsxs)(dt.Fragment,{children:[s&&u.type&&!["command","image"].includes(u.type.toLowerCase())&&(0,He.jsx)(Zt,{onClick:b,shortKeys:[8679,8629],children:n}),(0,He.jsx)(Zt,{onClick:x,shortKeys:[8629],children:e})]})]})]})},_l=hm;var Pl=require("react");var Fn=require("react/jsx-runtime"),Jt=()=>(0,Fn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Fn.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Fn.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 ym({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",Y);return(0,Ee.jsxs)("div",{className:l.search,children:[(0,Ee.jsx)("div",{className:l.searchIcon,children:(0,Ee.jsx)(Jt,{})}),(0,Ee.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Ee.jsx)("input",{ref:a,spellCheck:!1,onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:n,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===o?void 0:c.target.value),value:i||o,children:[o&&(0,Ee.jsx)("option",{children:o}),s.map(c=>(0,Ee.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var kl=(0,Pl.forwardRef)(ym);var Bn=require("react/jsx-runtime");function _t({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:u,isOpen:d,search:p}){let[g,h]=(0,Yt.useState)(0),m=(0,Yt.useRef)(null),x=()=>{s&&s(n),i(void 0),r(""),a(!1)},b=()=>{var f;if(o!==n&&s){s(n);return}if(l&&i){i(void 0),(f=m.current)==null||f.focus();return}if(p.length>0){r("");return}a(!1)};return(0,Yt.useEffect)(()=>{h(0)},[p,o]),(0,Bn.jsx)(jt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:b,onClose:x,children:(0,Bn.jsxs)(ml,{selected:g,setSelected:h,isOpen:d,onChangeOpen:a,page:o,children:[o===n&&(0,Bn.jsx)(kl,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:l,types:c,typePlaceholder:e}),u]})})}_t.Page=Nr;_t.List=Mr;_t.Image=cl;_t.ListItem=Or;_t.ActionsBar=_l;_t.Button=Zt;var A=_t;var G=require("react/jsx-runtime"),Sm=({suggestion:t,onUse:e,onDismiss:n,onTouched:o,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ja),l=(0,ms.useDispatch)(),c=_(br),u=(0,ms.useSelector)(h=>h.overlayInput.text);(0,Kr.useEffect)(()=>{t&&(l(Z.actions.reset()),l(Z.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Z.actions.commitSuggestion()))},[t]);let d=h=>{h.preventDefault(),p(u)},p=h=>{l(Qo(h)),e(h)},g=h=>m=>{u!==i?window.confirm(c("warning"))&&h(m):h(m)};return(0,Kr.useEffect)(()=>{o&&o(u!==i)},[o,t,u]),(0,G.jsxs)("div",{className:a.root,children:[(0,G.jsxs)("div",{className:a.content,children:[t.title&&(0,G.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,G.jsx)(hr,{labels:t.searchKeywords}),(0,G.jsx)(ll,{onUse:p,value:u})]}),(0,G.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,G.jsxs)("div",{children:[(0,G.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:(0,G.jsx)(es,{})}),(0,G.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:(0,G.jsx)(za,{})})]}),(0,G.jsxs)("div",{className:a.primaryButtons,children:[(0,G.jsx)(A.Button,{onClick:g(n),shortKeys:["esc"],children:c("dismiss")}),(0,G.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},gs=Sm;var Pt=require("@reduxjs/toolkit");var vm=["{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}"],xm=new RegExp(vm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Rl(t,e){let n=t.split(xm),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],l=r===n.length-2;o+=i.length;let c=o;if(l){let d=a.charAt(0),p=0;do c=d?e.indexOf(d,c+1):-1,p+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&p>2)return t}else c=a&&a!==""?e.indexOf(a,o):-1;let u=c===-1?e.slice(o):e.slice(o,c);s.push(u),o=c}return s.join("")}function Il(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Al={suggestions:[],fetchState:"idle",isInitialRequest:null},Ll={default:Al},Ml=t=>e=>{var n;return((n=e.textSuggestions[t])==null?void 0:n.suggestions)??[]},Ol=t=>e=>{var n;return((n=e.textSuggestions[t])==null?void 0:n.suggestions)??[]},Nl=t=>{let e=Object.keys(t.textSuggestions).map(n=>{var o;return(o=t.textSuggestions[n])==null?void 0:o.fetchState});return e.length===0?!0:e.every(n=>n!=="done")},en=t=>t.textSuggestions,Dl=t=>e=>e.text.startsWith(t),fs=(0,Pt.createAction)("textSuggestions/refresh"),Fe=(0,Pt.createAsyncThunk)("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=Ut(o);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(s,Hn(o),t);if(t==="default"){let u=i?l.filter(Dl(a)):l;e.dispatch(lt(u.slice(0,r)))}return l}),Kn=(0,Pt.createAsyncThunk)("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=o.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(s,{...Hn(o),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Dl(t))),i&&(l=l.map(u=>({...u,text:u.source!=="trie-with-typos"?Rl(u.text,t):u.text}))),l=Il(l,r),e.dispatch(lt(l)),l}),Hl=(0,Pt.createSlice)({name:"textSuggestions",initialState:Ll,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(Fe.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||Al;return{...e,[o]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(Fe.rejected,(e,n)=>{let o=n.meta.arg;e[o].fetchState="error"}).addCase(Fe.fulfilled,(e,n)=>{let o=n.meta.arg;e[o].fetchState="done",e[o].suggestions=n.payload}).addCase(Kn.pending,e=>{e.default.fetchState="loading"}).addCase(Kn.rejected,e=>{e.default.fetchState="error"}).addCase(Kn.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(L,()=>Ll)}}),{setTextSuggestions:Fl,setSuggestionState:Bl}=Hl.actions,Kl=Hl.reducer;var Vl=require("@reduxjs/toolkit");var Ul={contentType:null,suggestion:null},jl=t=>t.activeSuggestion.suggestion,zl=t=>t.activeSuggestion.contentType,ql=(0,Vl.createSlice)({name:"activeSuggestion",initialState:Ul,reducers:{setActiveSuggestion(t,e){let{contentType:n,suggestion:o}=e.payload;t.contentType=n,t.suggestion=o},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(L,()=>Ul)}}),{setActiveSuggestion:Be,resetActiveSuggestion:Ur}=ql.actions,Wl=ql.reducer;var Vr={};j(Vr,{enUS:()=>Cm,nlNL:()=>Tm});var Cm={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"}]},Tm={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 Gl=require("@reduxjs/toolkit"),wm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var $l=({ui:t})=>t.overlayCollapsed;var Xl=(0,Gl.createSlice)({name:"ui",initialState:wm,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:Un,setInputHasFocus:tn,setOverlayCollapsed:nn,setOpenOverlayWhenTyping:Ql,setOverlayCollapsedUserOverwrite:Zl}=Xl.actions,Jl=Xl.reducer;var Vn=E(require("react")),ec=require("react/jsx-runtime"),Yl=Vn.default.createContext(null),jn=({broadcastEvents:t,children:e})=>{let n=Vn.default.useMemo(()=>t,[]);return(0,ec.jsx)(Yl.Provider,{value:n,children:e})},he=()=>{let t=(0,Vn.useContext)(Yl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var on=require("@reduxjs/toolkit");var bm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Ke=t=>t.auth.isLoggedIn,tc=t=>t.auth.loginFetchState,nc=t=>t.auth.verifyFetchState,oc=t=>t.auth.showLoginOverlay,kt=(0,on.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),sc=(0,on.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:n}=e.extra;return n.requestLoginByEmail(t)}),zn=(0,on.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:n}=e.extra;return n.verifyLoginToken(t)}),rc=(0,on.createSlice)({name:"auth",initialState:bm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(kt.pending,e=>{e.loginFetchState="loading"}),t.addCase(kt.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(kt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(zn.pending,e=>{e.verifyFetchState="loading"}),t.addCase(zn.rejected,e=>{e.verifyFetchState="error"}),t.addCase(zn.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:hs,setShowLoginOverlay:ic}=rc.actions,ac=rc.reducer;var jr="SetActiveSuggestion",sn="ShowLoginOverlay",zr="UserLoggedIn",Ue="ApplySuggestion",qr="ApplyImageSuggestion",Em="ShowCommandPalette",_m=t=>({[jr]:e=>{t.dispatch(Bl(e.state)),t.dispatch(Be({contentType:e.contentType,suggestion:e.suggestion}))},[Em]:e=>{t.dispatch(re(e.isOpen)),e.page&&t.dispatch($(e.page))},[sn]:e=>{t.dispatch(ic(e))},[zr]:()=>{t.dispatch(kt())},[qr]:e=>{t.dispatch(Jo({suggestion:e.suggestion}))},[Ue]:e=>{t.dispatch(be({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),lc=_m;var Wr=require("react/jsx-runtime"),Pm=()=>{var h;let[t,e]=(0,cc.useState)(!1),n=(0,rn.useSelector)(jl),o=(0,rn.useSelector)(zl),s=(0,rn.useSelector)(en),r=(0,rn.useDispatch)(),i=he(),a=_(Vr),l=()=>{n!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ur()),r(tn(!0)),r(Z.actions.reset())},u=(m,x)=>{r(Ur()),r(tn(!0)),i.send(Ue,{text:m,suggestion:x})};if(n===null||o===null)return null;let d=(h=s[o])==null?void 0:h.suggestions.indexOf(n),p=d===0||d===null?void 0:()=>r(Be({contentType:o,suggestion:s[o].suggestions[d-1]})),g=d===s[o].suggestions.length-1||d===null?void 0:()=>r(Be({contentType:o,suggestion:s[o].suggestions[d+1]}));return(0,Wr.jsx)(jt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Wr.jsx)(gs,{onTouched:e,onDismiss:c,onUse:m=>u(m,n),suggestion:n,onNext:g,onPrevious:p})})},uc=Pm;var $r=require("react-redux");var ys=E(require("classnames")),_e=require("react"),Ss=require("react-redux");var dc=E(require("classnames"));var pc={root:"_root_1ukx5_1"};var mc=require("react/jsx-runtime"),km=({className:t,value:e,...n})=>{let o=y("TextInput",pc);return(0,mc.jsx)("input",{className:(0,dc.default)(t,o.root),type:"text",value:e,...n})},qn=km;var Gr={};j(Gr,{enUS:()=>Rm,nlNL:()=>Im});var Rm={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"}]},Im={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 gc={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 Lm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Am=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=_(Gr),i=y("LoginTokenDialog",gc),a=(0,Ss.useSelector)(nc),l=(0,Ss.useDispatch)(),c=T("productName"),[u,d]=(0,_e.useState)(t||""),[p,g]=(0,_e.useState)(0),[h,m]=(0,_e.useState)(""),x=(0,_e.useCallback)(async C=>{C.preventDefault(),l(sc({email:u})),g(1)},[n,u]),b=()=>{m(""),g(0)},f=(0,_e.useCallback)(async C=>{C.preventDefault();let k=Lm(C.target.elements.token.value);if(!k){m(r("verifyCodeError",{login:v}));return}l(zn({token:k}))},[n]),v=(0,_e.useMemo)(()=>C=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:C},"back-button"),[]);return(0,_e.useEffect)(()=>{a==="error"&&m(r("verifyCodeError",{login:v})),a==="done"&&o()},[a]),(0,K.jsx)(jt,{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})}),p===0&&(0,K.jsxs)("form",{onSubmit:x,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)(qn,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:u,onChange:C=>d(C.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,ys.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===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)(qn,{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,ys.default)(i.button),onClick:b,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,ys.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},fc=Am;var yc=require("react/jsx-runtime"),Mm=()=>{let t=(0,$r.useSelector)(oc),e=(0,$r.useSelector)(fl),n=T("adminUrl"),o=he(),s=()=>o.send(sn,!1),r=()=>{o.send(sn,!1),o.send(zr)};return(0,yc.jsx)(fc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},hc=Mm;var Kc=E(require("lodash.debounce")),ie=require("react"),ze=require("react-redux");var vs=require("@reduxjs/toolkit");var Om={data:null,fetchState:"idle"},Sc=t=>t.contentTypes.data,Wn=(0,vs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Nm=(0,vs.createSlice)({name:"contentTypes",initialState:Om,reducers:{},extraReducers:t=>{t.addCase(Wn.pending,e=>{e.fetchState="loading"}).addCase(Wn.rejected,e=>{e.fetchState="error"}).addCase(Wn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),vc=Nm.reducer;function Gn(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var xc=require("react");function Cc(t,e){(0,xc.useEffect)(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}var $n=require("react"),Ts=require("react-redux");var xs=require("@reduxjs/toolkit");var Tc={data:null,fetchState:"idle"},Cs=t=>{var r;let e=[],{visitorName:n}=t.info.visitorInfo??{},{agentName:o,agentNickname:s}=t.info.agentInfo??{};return o&&o!==n&&e.push(o),s&&s!==n&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},Pe=(0,xs.createAsyncThunk)("entities/getEntities",async(t,e)=>{let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):n.getEntities(r)}),Dm=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Hm=(0,xs.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,n)=>{e.fetchState="done",e.data=Dm(e.data?[...e.data,...n.payload]:n.payload)}).addCase(L,()=>Tc)}}),wc=Hm.reducer;var Xr={};j(Xr,{enUS:()=>Fm,nlNL:()=>Bm});var Fm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Bm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var bc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Rt=require("react/jsx-runtime"),Km=({onCopy:t,onUse:e})=>{let n=(0,$n.useRef)(null),o=y("EntitiesList",bc),s=_(Xr),r=(0,Ts.useSelector)(Cs),i=(0,Ts.useDispatch)();return(0,$n.useEffect)(()=>{i(Pe())},[]),(0,$n.useEffect)(()=>{n.current&&n.current.focus()},[n]),(0,Rt.jsxs)("div",{className:o.root,ref:n,tabIndex:-1,children:[r&&r.length>0&&(0,Rt.jsx)(A.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,Rt.jsx)(A.List,{children:r.map((a,l)=>(0,Rt.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Rt.jsx)("p",{className:o.empty,children:s("noResults")})]})},Ec=Km;var ke=require("react"),Xn=require("react-redux");var ws=require("@reduxjs/toolkit");var _c={data:null,fetchState:"idle"},Pc=t=>t.summary.data,kc=t=>t.summary.fetchState==="error",Ve=(0,ws.createAsyncThunk)("summary/getSummary",async(t,e)=>{let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let s=o.conversationQuery,r=await s();if(r.length===0)return Promise.reject(new Error("No messages are included"));let i=await n.getSummary(r);return{original:r,summary:i}}),Um=(0,ws.createSlice)({name:"summary",initialState:_c,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,n)=>{e.fetchState="done",n.payload&&(e.data=n.payload.summary)}).addCase(L,()=>_c)}}),Rc=Um.reducer;var Qr={};j(Qr,{enUS:()=>Vm,nlNL:()=>jm});var Vm={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."}]},jm={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 Ic={root:"_root_18y7z_1",actions:"_actions_18y7z_5",main:"_main_18y7z_11",textInput:"_textInput_18y7z_15",loading:"_loading_18y7z_34",error:"_error_18y7z_38"};var je=require("react/jsx-runtime"),zm=({onCopy:t})=>{let e=(0,ke.useRef)(null),n=y("SummaryForm",Ic),[o,s]=(0,ke.useState)(""),r=_(Qr),i=(0,Xn.useSelector)(Pc),a=(0,Xn.useSelector)(kc),l=(0,Xn.useDispatch)(),c=()=>{l(se({name:"summary copied to clipboard",data:{originalText:i,finalText:o},options:{includeConversationData:!0}})),t(o)},u=()=>{let d=document.getSelection();d&&l(se({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,ke.useEffect)(()=>{l(Ve())},[]),(0,ke.useEffect)(()=>{s(i||"")},[i]),(0,ke.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,ke.useEffect)(()=>{let d=p=>{p.key==="Enter"&&p.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[o]),(0,je.jsx)("div",{className:n.root,tabIndex:-1,children:a?(0,je.jsx)("p",{className:n.error,children:r("error")}):(0,je.jsxs)(ke.Fragment,{children:[(0,je.jsx)("div",{className:n.main,children:(0,je.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:n.textInput,ref:e,value:o,onCopy:u,onChange:d=>s(d.target.value)})}),(0,je.jsx)("div",{className:n.actions,children:(0,je.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Lc=zm;var Zr={};j(Zr,{enUS:()=>qm,nlNL:()=>Wm});var qm={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Wm={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var It=E(require("react")),Jn=require("react-redux");var Jr={};j(Jr,{enUS:()=>Gm,nlNL:()=>$m});var Gm={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"}]},$m={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 Ac={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 ln=require("@reduxjs/toolkit");var Yr={data:[],fetchState:"idle"},Mc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Oc=t=>t.answer.fetchState,Qn=(0,ln.createAction)("answer/resetKnowledgeSearch"),an=(0,ln.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:n}=e.extra,o=e.getState().answer.data,s=(i=e.getState().profile.data)==null?void 0:i.code;if(!s)throw new Error("Profile is not defined");let r=await n.knowledgeSearch({promptInstruction:t.promptInstruction,question:t.question},o,s);return{question:t.question,answer:r}}),Xm=(0,ln.createSlice)({name:"answer",initialState:Yr,reducers:{},extraReducers:t=>{t.addCase(an.pending,e=>{e.fetchState="loading"}).addCase(an.rejected,e=>{e.fetchState="error"}).addCase(an.fulfilled,(e,n)=>{e.fetchState="done",e.data=[...e.data,n.payload]}).addCase(L,()=>Yr).addCase(Qn,()=>Yr)}}),Nc=Xm.reducer;var Zn=require("react/jsx-runtime"),Dc=()=>(0,Zn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Zn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Zn.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 ee=require("react/jsx-runtime"),Qm=({onUse:t,onResetQuestion:e,question:n,promptInstruction:o})=>{let[s,r]=It.default.useState(""),{setSelected:i}=ut(),a=(0,It.useRef)(null),l=y("EntitiesList",Ac),c=_(Jr),u=(0,Jn.useDispatch)(),d=(0,Jn.useSelector)(Mc),p=(0,Jn.useSelector)(Oc),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&u(an({question:s,promptInstruction:o}))},h=(m,x)=>{u(se({name:"knowledge assist source viewed",data:{question:x,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,It.useEffect)(()=>{var m;n&&p==="idle"?u(an({question:n,promptInstruction:o})):(m=a.current)==null||m.focus()},[a,p]),(0,It.useEffect)(()=>{p==="done"&&(u(se({name:"knowledge assist question answered",data:{question:s||n,sources:d[d.length-1].answer.sources,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(0),r(""))},[p,d]),(0,ee.jsxs)("div",{className:l.root,children:[d.length>0&&(0,ee.jsx)("div",{className:l.alignRight,children:(0,ee.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,ee.jsxs)(A.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:x},b)=>(0,ee.jsx)(A.List,{children:(0,ee.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:b,description:x.answer,closeOnSelect:!0,onClick:()=>t(x.answer),onSourceClick:f=>h(f,m),sources:x.sources,styles:{title:l.question,description:l.answer},children:m})},`${x.answer}_${b}`)),p==="loading"&&(0,ee.jsx)("p",{className:l.status,children:c("loading")}),p==="error"&&(0,ee.jsx)("p",{className:l.status,children:c("error")}),(0,ee.jsxs)("form",{className:l.form,onSubmit:g,children:[(0,ee.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),(0,ee.jsx)("button",{type:"submit",className:l.submit,children:(0,ee.jsx)(Dc,{})})]})]})]})},Hc=Qm;var bs=require("@reduxjs/toolkit");var Zm={data:null,fetchState:"idle"},cn=t=>t.profile.data,Es=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],Yn=(0,bs.createAsyncThunk)("profile/getProfile",async(t,e)=>{let{deepdeskAPI:n}=e.extra,s=e.getState().conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return n.getProfile(s.profileCode)}),Jm=(0,bs.createSlice)({name:"profile",initialState:Zm,reducers:{},extraReducers:t=>{t.addCase(Yn.pending,e=>{e.fetchState="loading"}).addCase(Yn.rejected,e=>{e.fetchState="error"}).addCase(Yn.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Fc=Jm.reducer;var V=require("react/jsx-runtime"),Ym=200,eg=5,tg=4,ng=t=>t.reduce((e,n)=>[...e,...n.list.map(o=>({...o,type:n.value}))],[]),Bc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),og=()=>{let t=(0,ze.useDispatch)(),e=he(),n=_(Zr),[o,s]=(0,ie.useState)(!1),[r,i]=(0,ie.useState)(""),a=(0,ze.useSelector)(xl),l=(0,ze.useSelector)(cn),[c,u]=(0,ie.useState)(null),[d,p]=(0,ie.useState)([]),[g,h]=(0,ie.useState)(),m=(0,ze.useSelector)(Ke),x=T("showSearch"),b=T("showEntitiesCommand"),f=T("showSummaryCommand"),v=T("showKnowledgeSearch"),C=T("showImageSearch"),k=T("searchTriggerKey"),w=(0,ze.useSelector)(Sc),D=(0,ze.useSelector)(Cl),ne=(0,ze.useSelector)(vl),B=S=>or(D.filter(M=>M.type===S.toUpperCase()),S),I=[{value:"PERSONAL",label:n("personalSuggestions"),list:B("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:B("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:B("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:B("IMAGE"),listOrientation:"horizontal",shouldShow:C}].filter(S=>S.shouldShow),ve=[{label:n("entitiesClipboard"),onClick:()=>t($("entities")),shouldShow:b&&Bc(n("entitiesClipboard"),r),experimental:!0},{label:n("summaryClipboard"),onClick:()=>t($("summary")),shouldShow:f&&Bc(n("summaryClipboard"),r),experimental:!0},{label:r?`${n("knowledgeSearch")}: ${r}`:n("knowledgeSearch"),onClick:()=>t($("knowledgeSearch")),shouldShow:v,experimental:!0}].filter(S=>S.shouldShow),xe=(w==null?void 0:w.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:B(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],tr=(0,ie.useCallback)((0,Kc.default)((S,M)=>{t(Et({query:S,type:M,tags:["search-overlay"]}))},Ym),[]),vt=ng([...xe,...I]),Jp=(0,ie.useCallback)((S,M)=>{if(!M)return;let nt=[...I,...xe].find(({value:Dt})=>Dt===M);nt&&(t($("edit")),u(S),p(nt.list))},[t,c,xe]),nr=(0,ie.useCallback)((S,M)=>{switch(M.type){case"IMAGE":e.send(qr,{suggestion:M});break;default:e.send(Ue,{text:S,suggestion:M})}t(re(!1))},[t]),Yp=S=>{Gn(S.text),t(se({name:"entity copied",data:{entity:S,type:"copy"}})),t(re(!1))},ed=S=>{e.send(Ue,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(se({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t($("search")),t(Qn()),t(re(!1))},td=S=>{Gn(S),t(re(!1))},nd=S=>{e.send(Ue,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(re(!1))},od=c===null||d.indexOf(c)-1<0?void 0:()=>u(d[d.indexOf(c)-1]),sd=c===null||d.indexOf(c)===d.length-1?void 0:()=>u(d[d.indexOf(c)+1]);function or(S,M){return S.slice(0,g?10:M.toLowerCase()==="image"?tg:eg)}function Fi(S,M,nt){return M.reduce((Dt,go)=>nt&&g===nt?go.length+Dt:or(go,nt).length+Dt,S)}function Nt(S){return M=>{o?window.confirm(n("warning"))&&(S(M),s(!1)):S(M)}}return(0,ie.useEffect)(()=>{r?tr(r,g):t(us())},[r,g]),(0,ie.useEffect)(()=>{m&&t(Wn())},[m]),Cc(k,()=>t(re(!0))),!x||!l?null:(0,V.jsxs)(A,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:Nt(S=>t(re(S))),onChangeType:S=>h(S),onChangePage:Nt(S=>t($(S))),selectedType:g,search:r,page:a,isOpen:ne,types:[...xe,...I],children:[(0,V.jsx)(A.Page,{id:"search",children:(0,V.jsxs)(A.ActionsBar,{list:[...ve.map(S=>({text:S.label,type:"command"})),...vt.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:S},M)=>nr(S,vt[M]),onSecondary:(S,M)=>Jp(vt[M],vt[M].type),children:[ve.length>0&&(0,V.jsx)(A.List,{heading:n("commands"),children:ve.map((S,M)=>(0,V.jsx)(A.ListItem,{index:Fi(M,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...xe,...I].map(({value:S,label:M,list:nt,lineClamp:Dt,listOrientation:go},rd)=>(0,V.jsx)(A.List,{heading:M,orientation:go==="horizontal"?"horizontal":"vertical",children:or(nt,S).map((Ce,id)=>(0,V.jsx)(A.ListItem,{index:Fi(ve.length+id,[...xe,...I].slice(0,rd).map(({list:ad})=>ad),S),closeOnSelect:!1,lineClamp:Dt,onClick:()=>nr(Ce.text,Ce),description:S!=="IMAGE"?Ce.title&&Ce.text:void 0,children:S==="IMAGE"?(0,V.jsx)(A.Image,{title:Ce.title||Ce.text,src:Ce.image}):Ce.title||Ce.text},`${Ce.id}-${Ce.text}`))},S))]})}),(0,V.jsx)(A.Page,{id:"edit",onDismiss:Nt(()=>{t($("search")),u(null)}),children:c&&(0,V.jsx)(gs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t($("search")),u(null),p([])},onNext:sd,onPrevious:od,onUse:S=>{t($("search")),nr(S,c),t(re(!1)),p([]),u(null)}})}),(0,V.jsx)(A.Page,{id:"entities",title:n("entitiesTitle"),isExperimental:!0,onDismiss:Nt(()=>{t($("search"))}),children:(0,V.jsx)(Ec,{onUse:nd,onCopy:Yp})}),(0,V.jsx)(A.Page,{id:"summary",title:n("summaryTitle"),isExperimental:!0,onDismiss:Nt(()=>{t($("search"))}),children:(0,V.jsx)(Lc,{onCopy:td})}),(0,V.jsx)(A.Page,{id:"knowledgeSearch",title:n("knowledgeSearch"),isExperimental:!0,onDismiss:Nt(()=>{t(Qn()),t($("search"))}),children:(0,V.jsx)(Hc,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:ed,onResetQuestion:()=>{t(Qn()),i("")}})})]})},Uc=og;var un=require("react/jsx-runtime"),sg=()=>{let t=T("showSearch"),e=T("isEmbedded");return(0,un.jsxs)(Vc.Fragment,{children:[t&&(0,un.jsx)(Uc,{}),(0,un.jsx)(uc,{}),e&&(0,un.jsx)(hc,{})]})},jc=sg;var zc=require("react-redux");var eo=require("react/jsx-runtime"),rg=({children:t})=>{let n=T("locale").replace("-","");return(0,eo.jsx)(dr.Provider,{value:n,children:t})},ig=({store:t,customStyles:e={},children:n})=>(0,eo.jsx)(zc.Provider,{store:t,children:(0,eo.jsx)(rg,{children:(0,eo.jsx)(vn.Provider,{value:e,children:n})})}),to=ig;var Rs=E(require("classnames")),mn=require("react"),We=require("react-redux");var qc=require("react");function Wc(t,e){let[n,o]=(0,qc.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[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){P.error(i)}}]}function _s(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}var $c=E(require("classnames")),qe=require("react");var ei={};j(ei,{enUS:()=>ag,nlNL:()=>lg});var ag={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"}]}]},lg={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 Gc={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var mt=require("react/jsx-runtime"),ti=(t,e,n)=>o=>(0,mt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),cg=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o})=>{let s=_(ei),r=he(),i=y("Login",Gc),a=T("productName"),l=(0,qe.useCallback)(m=>{m.preventDefault(),o&&o(parseInt(m.target.value,10))},[]),c=(0,qe.useCallback)(m=>{m.preventDefault(),r.send(sn,!0)},[e]),u=(0,qe.useMemo)(()=>m=>(0,mt.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[e]),d=(0,qe.useCallback)(m=>(0,mt.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:p,hour:g,day:h}=(0,qe.useMemo)(()=>({min:ti(i,60*10,l),hour:ti(i,60*60,l),day:ti(i,60*60*12,l)}),[]);return(0,mt.jsxs)("div",{className:(0,$c.default)(t,i.root),children:[s("loginPlease",{login:n?d:u,productName:a}),o&&(0,mt.jsxs)(qe.Fragment,{children:[(0,mt.jsx)("br",{}),s("snooze",{min:p,hour:g,day:h})]})]})},Ps=cg;var Qc=require("react-redux");var Xc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var no=require("react/jsx-runtime"),ug=({title:t})=>{let e=y("SearchTrigger",Xc),n=(0,Qc.useDispatch)();return(0,no.jsxs)("button",{type:"button",className:e.root,onClick:()=>n(re(!0)),children:[(0,no.jsx)(Jt,{}),(0,no.jsx)("span",{className:e.text,children:t})]})},Zc=ug;var ru=require("react");var ou=require("interweave"),dn=require("react"),ks=require("react-redux");var Jc=require("react");function Yc(t,e,n){(0,Jc.useEffect)(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var pg=/[.*+?^${}()|[\]\\]/g,dg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function mg(t){return t.replace(pg,"\\$&")}function gg(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function ni(t){return t.search(dg)}function eu(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${mg(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function tu(t){return t.replace(Kt,'<mark data-type="placeholder">$1</mark>')}function pn(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function fg(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 oi(t,e,n={}){if(e){let o=gg(e.toLowerCase(),t.toLowerCase()),s=pn(t.substring(o,t.length));if(n.stripAgentPart){let l=t.substring(0,o),c=ni(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ya).length>3||e.length>30?fg(e.trim(),o):0;return`${`${i>0?"\u2026":""}${pn(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var nu={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var si=require("react/jsx-runtime"),yg=["search","personal-collection-search","studio-search"];function Sg(t,e,n,o={}){let s="";return yg.includes(e)?s=eu(oi(t,n,{stripAgentPart:!0}),o.searchKeywords??[n]):s=oi(t,n,o),o.placeholders===!0&&(s=tu(s)),s}var vg=()=>{},xg=({index:t,selected:e,suggestion:n})=>{let o=T("inlineSuggestions"),s=(0,ks.useSelector)(Ut),r=(0,ks.useDispatch)(),i=y("TextSuggestion",nu),a=(0,dn.useRef)(null);(0,dn.useEffect)(()=>{let c=setTimeout(()=>{r(Na({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(c)}},[n]),Yc(a,"click",()=>{r(Yo(t)),r(be({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,dn.useMemo)(()=>Sg(n.text,n.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:n.searchKeywords}),[o,n.text,n.source,s,n.searchKeywords]);return n.source==="gpt"?null:(0,si.jsx)(N,{ref:a,as:"button",selected:e,onClick:vg,children:(0,si.jsx)(ou.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},su=xg;var ri=require("react/jsx-runtime"),Cg=({suggestions:t,selectedIndex:e})=>(0,ri.jsx)(ru.Fragment,{children:t.slice().map((n,o)=>(0,ri.jsx)(su,{index:o,selected:o===e,suggestion:n},`${n.text}-${n.source}`)).reverse()}),iu=Cg;var ii={};j(ii,{enUS:()=>Tg,nlNL:()=>wg});var Tg={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"}]},wg={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 au={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"),bg=({inline:t=!1,textSuggestions:e,selectedIndex:n})=>{let o=y("SuggestionsOverlay",au),s=_(ii),r=T("inlineSuggestions"),i=(0,We.useSelector)(_s),a=Ia(),l=(0,We.useDispatch)(),c=(0,mn.useRef)(null),u=T("searchTriggerKey"),d=T("productName"),p=(0,We.useSelector)($l),g=(0,We.useSelector)(Ke),h=(0,We.useSelector)(Uo),[m,x]=(0,mn.useState)(null),b=T("showSearch"),f=T("showTextSuggestions"),v=T("adminUrl"),C=T("isEmbedded"),[k,w]=Wc("dd-snooze-until-ms",0),D=p||k>Date.now(),ne=e.filter(ve=>ve.source!=="gpt").length,B=()=>{D&&w(0),l(Zl(!D))},I=ve=>{let xe=Date.now()+ve*1e3;w(xe),P.info(`Snooze until: ${new Date(xe)}`),l(nn({collapse:!0}))};return(0,mn.useEffect)(()=>{ne===0&&x(null)},[e,ne]),Gt(()=>{l(nn({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||g===null||h===!1?null:g===!1?(0,H.jsxs)("div",{ref:c,className:(0,Rs.default)(o.root,{[o.isCollapsed]:D,[o.isInline]:t}),"data-inline":t,children:[!D&&(0,H.jsxs)("div",{className:o.triggers,children:[(0,H.jsx)("div",{style:{flex:1}}),(0,H.jsx)("div",{className:o.triggersRight,children:(0,H.jsx)(wt,{className:o.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})})]}),(0,H.jsx)("div",{className:o.toggleButtonWrapper,children:(0,H.jsx)(wt,{className:o.toggleButton,title:s("open",{productName:d}),onClick:B,isCollapsed:!0})}),(0,H.jsx)("div",{className:o.collapsible,children:(0,H.jsx)(Ps,{loginUrl:v,isEmbedded:C,onSnooze:I})})]}):!a||!i?null:(0,H.jsxs)("div",{ref:c,className:(0,Rs.default)(o.root,{[o.isCollapsed]:D,[o.isInline]:t}),"data-inline":t,children:[!D&&(0,H.jsxs)("div",{className:o.triggers,children:[(0,H.jsx)("div",{style:{flex:1},children:b&&(0,H.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>x(s(as()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>x(null),children:(0,H.jsx)(Zc,{title:s("search")})})}),(0,H.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,H.jsx)("div",{className:(0,Rs.default)(!m&&o.hintsHidden,o.hints),children:m}),(0,H.jsx)(wt,{className:o.toggleButton,title:s("collapse"),onClick:B,isCollapsed:!1})]})]}),(0,H.jsx)("div",{className:o.toggleButtonWrapper,children:(0,H.jsx)(wt,{className:o.toggleButton,title:s("open",{productName:d}),onClick:B,isCollapsed:!0})}),ne>0&&f&&(0,H.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,H.jsx)(Re,{children:(0,H.jsx)(iu,{suggestions:e,selectedIndex:n})})})]})},Eg=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Is=(0,We.connect)(Eg)(bg);var js=E(require("classnames")),Pu=require("interweave"),Qe=require("react"),ku=require("react-redux");var lu=require("react"),_g=["div","span","mark","strong","b","i","u","em"];function ai(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(_g.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),(0,lu.cloneElement)(o,{children:ai(i,e,n+1)})]}return[...t,...e]}function Ge(t){return t.tagName.toLowerCase()==="textarea"}var cu={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var fu=require("interweave"),Os=require("react");var ci=E(require("classnames")),ye=require("react");var Ls=require("react"),Pg=["bottom","height","left","right","top","width"],kg=(t={},e={})=>Pg.some(n=>t[n]!==e[n]),$e=new Map,uu,pu=()=>{let t=[],e=[];$e.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();kg(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{$e.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),uu=window.requestAnimationFrame(pu)};function Rg(t,e){return{observe(){let n=$e.size===0;if($e.has(t)){let o=$e.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else $e.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&pu()},unobserve(){let n=$e.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||$e.delete(t),$e.size||cancelAnimationFrame(uu)}}}}function li(t){let[e,n]=(0,Ls.useState)(null);return(0,Ls.useLayoutEffect)(()=>{if(!t.current)return;let o=Rg(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}var gn=require("react"),mu=require("react-dom");var du={root:"_root_1jq08_1"};var gu=({children:t})=>{let[e,n]=(0,gn.useState)(null),o=(0,gn.useContext)(vn);return(0,gn.useLayoutEffect)(()=>{let s=document.createElement("div");return bt(s),s.classList.add(du.root),o!=null&&o.rootNode&&s.classList.add(o==null?void 0:o.rootNode),document.body.appendChild(s),n(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?(0,mu.createPortal)(t,e):null};var Me={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 As=require("react/jsx-runtime"),fn=(t=!1)=>{let[e,n]=(0,ye.useState)(t),o=(0,ye.useCallback)(()=>n(!0),[]),s=(0,ye.useCallback)(()=>n(!1),[]),r=(0,ye.useCallback)(()=>n(a=>!a),[]),i=(0,ye.useRef)(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function ui(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var hn=({className:t,triggerRef:e,boundaryRef:n=(0,ye.createRef)(),position:o="above",align:s="center",children:r,toStyle:i=ui,...a})=>{let l=li(e),c=li(n),u=(0,ye.useMemo)(()=>i(l,c,0),[l,c]);return(0,As.jsx)(gu,{children:(0,As.jsx)("div",{className:(0,ci.default)(Me.ref,{[Me.positionAbove]:o==="above",[Me.positionBelow]:o==="below",[Me.positionLeft]:o==="left",[Me.positionRight]:o==="right",[Me.alignStart]:s==="start",[Me.alignCenter]:s==="center",[Me.alignEnd]:s==="end"}),style:u,...a,role:"dialog",children:(0,As.jsx)("div",{className:(0,ci.default)(t,Me.root),children:r})})})};var gt=require("react/jsx-runtime"),Ig=({inputStyle:t,inputElement:e})=>{let n=y("TabCompletion",me),o=fn(document.activeElement===e);return Gt(()=>o.close()),(0,Os.useEffect)(()=>{let s=()=>o.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),(0,gt.jsxs)(Os.Fragment,{children:[(0,gt.jsx)("mark",{className:me.caret,ref:o.triggerRef}),o.opened&&(0,gt.jsx)(hn,{className:n.popoverSuggestionsRoot,triggerRef:o.triggerRef,position:"above",align:"start",children:(0,gt.jsx)("div",{style:t,className:n.suggestionsOverlayInputStyles,children:(0,gt.jsx)(Is,{inline:!0})})})]})},Ms=class extends fu.Matcher{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(e,n){var o;return this.props=n,this.charCounter=0,this.onlyAtEnd=n.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(Ge(n.inputElement)?n.inputElement.value.length:(o=n.inputElement.textContent)==null?void 0:o.length)??0,this.found=!1,e}match(e){if(this.found||!this.props||this.props.selection===null)return null;let[n,o]=this.props.selection;if(n!==o||this.onlyAtEnd&&n!==this.charLength)return null;let s=n,i=s>=this.charCounter&&s<=this.charCounter+e.length?{index:ni(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,n){return(0,gt.jsx)(Ig,{inputStyle:n.inputStyle,inputElement:n.inputElement},"caret")}asTag(){return"mark"}};var vu=E(require("classnames")),xu=require("interweave"),Bs=require("react");function hu(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ns(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function yu(t){return t!=null}var Su=E(require("classnames")),Ds=require("react");var pi=require("react/jsx-runtime"),Hs=(0,Ds.forwardRef)(({className:t,children:e,...n},o)=>{let s=(0,Ds.useRef)(null),r=y("TabCompletion",me);return(0,pi.jsx)("div",{ref:Ns([s,o]),className:(0,Su.default)(t,r.popoverContentContainer),...n,children:(0,pi.jsx)("div",{className:r.popoverContent,children:e})})});var ft=require("react/jsx-runtime"),Lg=t=>e=>{let n=ui(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},Ag=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=y("TabCompletion",me),i=fn(),a=(0,Bs.useMemo)(()=>Lg(t.getBoundingClientRect()),[t]),[l,c]=ts(t);return(0,Bs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,ft.jsxs)("span",{children:[(0,ft.jsx)("mark",{ref:Ns([l,i.triggerRef]),className:(0,vu.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&(0,ft.jsx)(hn,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,ft.jsx)(Hs,{style:n,children:(0,ft.jsx)("div",{className:r.hintText,children:s})})})]})},Fs=class extends xu.Matcher{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(o=>({...o,keywordRegex:new RegExp(`\\b${hu(o.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let n=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(yu);if(n.length===0)return null;let o=n.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(e,n){return(0,ft.jsx)(Ag,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:e},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Us=E(require("classnames")),Eu=require("interweave"),Q=require("react"),_u=require("react-redux");var di=require("react/jsx-runtime"),Cu=()=>(0,di.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,di.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 ht=require("react"),oo=require("react-redux"),wu=E(require("lodash.debounce"));var Tu={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Ks(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch{return null}}function mi(t){return t.replace("https://www.","").replace("https://","")}var Se=require("react/jsx-runtime"),Mg=3,Og=t=>({image:t.image||"",text:`https://${t.text}`,id:t.id,title:t.title}),Ng=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=Mg})=>{let r=y("LinkSearch",Tu),[i,a]=(0,ht.useState)(""),l=(0,oo.useDispatch)(),c=(0,oo.useSelector)(Ml("url")),u=(0,oo.useSelector)(Tl("URL",Og)),[d,p]=(0,ht.useState)(u.length-1),g=T("fallbackImage"),h=f=>{let v=f.target;a(v.value)},m=(f,v)=>{f.stopPropagation(),f.preventDefault(),window.open(v,"_blank")},x=f=>{var k;let v=d-1<0?u.length-1:d-1,C=d+1===u.length?0:d+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&p(v),f.code==="ArrowDown"&&p(C),f.code==="Enter"&&t(((k=u[d])==null?void 0:k.text)||i)},b=(0,ht.useCallback)((0,wu.default)(f=>{l(Et({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,ht.useEffect)(()=>{i&&b(i)},[i]),(0,ht.useEffect)(()=>()=>{l(us())},[]),(0,Se.jsxs)("div",{className:r.root,children:[(0,Se.jsx)(Re,{withDivider:!0,children:(i?u:c).slice(0,s).map((f,v)=>(0,Se.jsx)(N,{selected:d===v,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:(0,Se.jsxs)(F,{children:[(0,Se.jsx)(F.Image,{src:Ks(f,"small",g||void 0),title:f.title||f.text}),(0,Se.jsxs)(F.Content,{className:r.content,cropText:!0,children:[(0,Se.jsx)(F.Title,{children:f.title||mi(f.text)}),f.title&&mi(f.text)]}),(0,Se.jsx)(N.Actions,{children:(0,Se.jsx)(N.ActionButton,{label:o,onClick:C=>m(C,f.text)})})]})},f.text))}),(0,Se.jsx)(qn,{value:i,onChange:h,autoFocus:!0,placeholder:n,onKeyUp:x})]})},bu=Ng;var gi={};j(gi,{enUS:()=>Dg,nlNL:()=>Hg});var Dg={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Hg={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var X=require("react/jsx-runtime"),Fg=(0,Q.forwardRef)((t,e)=>{let n=y("TabCompletion",me);return(0,X.jsx)("mark",{ref:e,className:(0,Us.default)(n.matchSelection)},"selection-start")}),Bg=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=_(gi),i=y("TabCompletion",me),a=(0,Q.useRef)(null),l=(0,Q.useRef)(null),[c,u]=(0,Q.useState)(null),d=(0,_u.useDispatch)(),p=fn(document.activeElement===o),[g]=(0,Q.useState)(()=>document.createRange());p.triggerRef.current=g,(0,Q.useEffect)(()=>()=>g.detach(),[]),(0,Q.useEffect)(()=>{let m=t.current,x=a.current;!m||!x||(g.setStart(m,0),g.setEnd(x,0))},[t.current,a.current]),Gt(()=>{p.close()});let h=(0,Q.useCallback)(m=>{let x=g.toString(),b=/^http(s?):\/\//.test(m)?m:`https://${m}`;d($o({text:`[${x}](${b})`}))},[]);return(0,X.jsxs)("span",{children:[(0,X.jsx)("mark",{ref:a,className:(0,Us.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":p.opened?"true":"false",children:s}),p.opened&&(0,X.jsx)(hn,{className:i.popoverRoot,triggerRef:p.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,X.jsxs)(Hs,{style:n,ref:l,children:[(0,X.jsx)("div",{className:(0,Us.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,X.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>u("insertLink"),children:[(0,X.jsx)(Cu,{}),(0,X.jsx)("span",{children:"\xA0"}),(0,X.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,X.jsx)(bu,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{u(null),p.close()}})]})})]},"selection-end")},Vs=class extends Eu.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,n){return this.props=n,this.charCount=0,this.startRef=(0,Q.createRef)(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,o]=this.props.selection;if(n===o)return null;let s=this.foundIndex===0?n:o,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,n){return n.isStart?(0,X.jsx)(Fg,{ref:this.startRef}):(0,X.jsx)(Bg,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};var Xe=require("react/jsx-runtime"),Kg=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",cu),u=T("insertLink"),d=T("showMidSentenceSuggestions"),p=T("inlineSuggestions"),g=os(a),h=(0,Qe.useRef)(null);(0,Qe.useEffect)(()=>{Ge(a)&&g&&ss(a,g)},[g]);let m=(0,Qe.useCallback)(f=>{if(!s||!n)return f;let v=[(0,Xe.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Xe.jsx)("span",{className:(0,js.default)(c.tabText,c.resetIndent),"data-source":l,children:n},"tabText")];return o&&v.push((0,Xe.jsx)("span",{className:(0,js.default)(c.hint,c.resetIndent),children:(0,Xe.jsx)(No,{keyCode:"tab"},"tabHint")})),ai(f,v)},[s,n,o]),x=(0,Qe.useMemo)(()=>{let f=[];return p&&f.push(new Ms("inline")),u&&f.push(new Vs("selection")),f.push(new qt("placeholders")),r&&f.push(new Fs("keywords")),f},[p,u,r]),b=(0,Qe.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,Xe.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:b,children:[(0,Xe.jsx)(Pu.Interweave,{tagName:"span",containerTagName:"div",className:(0,js.default)(c.container,c.agentText),disableLineBreaks:Ge(a),content:e||"\u200B",onAfterParse:m,matchers:x,selection:g,keywordMatches:i,inputElement:a,inputStyle:b,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!d}),(0,Xe.jsx)("br",{})]}):null},Ug=({input:t,ui:e,settings:n,styleSuggestions:o,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??pn(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:u}=e,{isSupported:d}=s,{showTabCompletion:p,visible:g,showStyleSuggestions:h}=n;return{showTabHint:u,showStyleSuggestions:h,showTabCompletion:p,content:l,tabText:c,source:a,keywordMatches:((m=o.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},Ru=(0,ku.connect)(Ug)(Kg);var xp=E(require("classnames")),Cp=require("react"),z=require("react-redux");var yt=require("@reduxjs/toolkit");var Iu={list:[],fetchState:"idle",isInitialRequest:null},Au=t=>t.autoflows.list||[],Lu=t=>e=>{var n;return(n=e.list)==null?void 0:n.find(o=>o.triggerPayload===t)},Ze=(0,yt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(t)}),fi=(0,yt.createAsyncThunk)("autoflows/start",async(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.startAutoflowSession(t),await n(Ze(t.platformSessionId))}),hi=(0,yt.createAsyncThunk)("autoflows/stop",async(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.stopAutoflowSession(t.platformSessionId),await n(Ze(t.platformSessionId))}),Vg=(0,yt.createSlice)({name:"autoflows",initialState:Iu,reducers:{},extraReducers:t=>{t.addCase(fi.pending,(e,n)=>{let o=Lu(n.meta.arg.triggerPayload)(e);o.state="Started",o.isBusy=!0}),t.addCase(hi.pending,(e,n)=>{let o=Lu(n.meta.arg.triggerPayload)(e);o.state="Aborted",o.isBusy=!0}),t.addCase(Ze.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ze.rejected,e=>{e.fetchState="error"}),t.addCase(Ze.fulfilled,(e,n)=>{e.list=n.payload,e.fetchState="done"}),t.addCase(L,()=>Iu)}}),Mu=(0,yt.createAsyncThunk)("autoflows/openStream",(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");let s=o.openStream(t);s.on("sessionAborted",()=>{n(Ze(t))}),s.on("sessionCompleted",()=>{n(Ze(t))})}),Ou=(0,yt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(t)}),Nu=Vg.reducer;var St=require("@reduxjs/toolkit");var Du={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Hu=t=>t.customMessages.list,Fu=t=>e=>!!e.customMessages.sentSuggestions.find(n=>n===t),Bu=t=>e=>!!e.customMessages.answeredSuggestions.find(n=>n===t),Ku=t=>e=>!!e.customMessages.errorSuggestions.find(n=>n===t),so=(0,St.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(t)}),zs=(0,St.createAsyncThunk)("customMessages/send",async(t,e)=>{let{platformSessionId:n,suggestion:o}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(n,o)}),qs=(0,St.createAsyncThunk)("customMessages/answer",async(t,e)=>{let{platformSessionId:n,reply:o}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(n,o)}),Uu=(0,St.createSlice)({name:"customMessages",initialState:Du,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(so.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(so.rejected,e=>{e.fetchState="error"}).addCase(so.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload||[]}).addCase(zs.pending,(e,n)=>{e.sentSuggestions.push(n.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(o=>n.meta.arg.suggestion.text!==o)}).addCase(zs.rejected,(e,n)=>{let o=e.sentSuggestions.indexOf(n.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(o,1))}).addCase(qs.pending,(e,n)=>{e.sentSuggestions.push(n.meta.arg.suggestion.text),e.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(qs.rejected,(e,n)=>{let o=e.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(o,1)),e.answeredSuggestions.splice(o,1)}).addCase(L,()=>Du)}}),Vu=(0,St.createAsyncThunk)("customMessages/openStream",(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.openStream(t).on("customMessageSuggestion",r=>{n(Uu.actions.onCustomMessage(r))})}),ju=(0,St.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(t)}),zu=Uu.reducer;var ro=require("@reduxjs/toolkit"),jg={jwt:null,accountUrl:null,interval:null},qu=t=>e=>{let{exchangeToken:{jwt:n,accountUrl:o}}=e;return n&&o?`${o}/apis/admin/session/jwt/?jwt=${n}&redirect=${t}`:null},yi=(0,ro.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:n}=e.extra,o=await n.getTemporaryExchangeToken();return{accountUrl:n.client.baseUrl,jwt:o}}),Si=(0,ro.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:n=1e3*60*30}=t,{dispatch:o}=e;return o(yi()),setInterval(()=>o(yi()),n)}),Wu=(0,ro.createSlice)({name:"exchangeToken",initialState:jg,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(yi.fulfilled,(e,n)=>{e.jwt=n.payload.jwt,e.accountUrl=n.payload.accountUrl}),t.addCase(Si.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollExchangeToken:Gu}=Wu.actions,$u=Wu.reducer;function Xu(t){let{customMessages:e,autoflows:n}=t;return n.fetchState==="loading"&&n.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var sp=require("react"),rp=require("react-redux");var tp=E(require("classnames")),np=require("react");var Zu=E(require("classnames"));var Qu={root:"_root_838fd_1"};var Yu=require("react/jsx-runtime"),zg=({className:t,children:e})=>{let n=y("Unicode",Qu);return(0,Yu.jsx)("span",{className:(0,Zu.default)(t,n.root),children:e})},Ju=zg;var ep={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 vi={};j(vi,{enUS:()=>qg,nlNL:()=>Wg});var qg={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"}]},Wg={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 ae=require("react/jsx-runtime"),$g=({disabled:t,state:e,displayName:n,description:o,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",ep),a=_(vi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,ae.jsxs)(N,{className:(0,tp.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,ae.jsx)(F,{children:(0,ae.jsxs)(F.Content,{children:[(0,ae.jsxs)(F.Title,{children:[e&&(0,ae.jsx)("span",{className:i.stateBadge,children:a(e)}),n]}),(0,ae.jsx)("span",{children:o})]})}),(0,ae.jsx)(N.Actions,{fixed:e==="Started",children:(0,ae.jsx)(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,ae.jsxs)(np.Fragment,{children:[(0,ae.jsx)(Ju,{children:c})," ",(0,ae.jsx)("span",{children:a(l)})]})})})]})},op=$g;var xi=require("react/jsx-runtime"),Xg=(t,e)=>{let n=e.filter(o=>o.state==="Started");return n.length>0?n.indexOf(t)===-1:!1},Qg=({autoflows:t,onStartAutoflow:e,onStopAutoflow:n,platformSessionId:o})=>(0,xi.jsx)(sp.Fragment,{children:t.map(s=>(0,xi.jsx)(op,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Xg(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:o,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:o,triggerPayload:s.triggerPayload})},s.displayName))}),Zg=({autoflows:t,conversation:e})=>{var n;return{autoflows:t.list,platformSessionId:(n=e.current)==null?void 0:n.sessionId}},Jg={onStartAutoflow:fi,onStopAutoflow:hi},ip=(0,rp.connect)(Zg,Jg)(Qg);var Ws=require("react"),lp=require("react-redux"),wi=E(require("classnames"));var Ci=require("react/jsx-runtime"),Ti=()=>(0,Ci.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Ci.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var ap={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 Oe=require("react/jsx-runtime"),Yg=({entities:t})=>{let e=y("EntitiesWidgetList",ap),[n,o]=(0,Ws.useState)(void 0),s=(0,lp.useDispatch)(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Gn(a.text),s(se({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Ws.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:(0,Oe.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Oe.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Oe.jsx)("span",{className:e.entityText,children:a.text}),(0,Oe.jsxs)("span",{className:e.iconWrapper,children:[(0,Oe.jsx)("span",{className:(0,wi.default)(e.icon),children:(0,Oe.jsx)(Ti,{})}),(0,Oe.jsx)("span",{className:(0,wi.default)(e.icon,n===l&&e.iconClicked),children:(0,Oe.jsx)(Ti,{})})]})]},a.text))})},cp=Yg;var up=E(require("classnames")),bi=require("react"),Lt=require("react-redux");var io={};j(io,{enUS:()=>ef,nlNL:()=>tf});var ef={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"}]},tf={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 Je={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 te=require("react/jsx-runtime"),nf=({suggestion:t})=>{let e=_(io),n=(0,Lt.useDispatch)(),o=(0,Lt.useSelector)(Fu(t.text)),s=(0,Lt.useSelector)(Bu(t.text)),r=(0,Lt.useSelector)(Ku(t.text)),i=(0,Lt.useSelector)(Bo),{replyOptions:a}=t,l=(0,bi.useCallback)(u=>{u.preventDefault(),u.stopPropagation(),!(o||!i)&&n(zs({platformSessionId:i,suggestion:t}))},[t,o,n,i]),c=(0,bi.useCallback)(u=>{if(u.preventDefault(),u.stopPropagation(),!i||!a)return;let d=parseInt(u.target.dataset.index,10),p=a[d];n(qs({platformSessionId:i,reply:p,suggestion:t}))},[t,o,n,i]);return(0,te.jsxs)(N,{onClick:l,className:(0,up.default)(Je.root,{[Je.isUsed]:o,[Je.hasError]:r}),children:[(0,te.jsx)(F,{children:(0,te.jsxs)(F.Content,{children:[(0,te.jsxs)(F.Title,{className:Je.title,children:[t.text," ",(0,te.jsx)(Do,{className:Je.label,children:"analyse tool"})," ",r&&(0,te.jsx)("span",{className:Je.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,te.jsx)("ul",{className:Je.quickReplies,children:a.map(u=>(0,te.jsx)("li",{className:Je.quickReply,children:u.title},u.title))})]})}),(0,te.jsxs)(N.Actions,{fixed:r||o,children:[a&&a.length>0&&(0,te.jsx)(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((u,d)=>(0,te.jsx)(N.DropdownItem,{index:d,label:u.title,onClick:c},u.title))}),(0,te.jsx)(N.ActionButton,{primary:!0,disabled:o,onClick:l,label:e(o?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},pp=nf;var Ei=require("react/jsx-runtime"),dp=()=>(0,Ei.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ei.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 fp=require("react-redux");var mp=require("react");var le=require("react/jsx-runtime"),of=({suggestion:t,lines:e,onEdit:n,onUse:o})=>{var p;let s=t.text||t.url||t.message,r=ps(s),i=_(io),a=T("showImages"),l=T("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),o(s)},u=g=>{g.preventDefault(),g.stopPropagation(),n(t)},d=(0,mp.useCallback)(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return(0,le.jsxs)(N,{onClick:c,"data-testid":"edit-suggestion",children:[(0,le.jsxs)(F,{children:[a&&t.image&&(0,le.jsx)(F.Image,{src:Ks(t,"small",l||void 0),title:t.title}),(0,le.jsxs)(F.Content,{children:[t.title&&(0,le.jsx)(F.Title,{children:t.title}),t.searchKeywords&&((p=t.searchKeywords)==null?void 0:p.length)>0&&(0,le.jsx)(N.Labels,{labels:t.searchKeywords}),(0,le.jsx)(F.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,le.jsxs)(N.Actions,{children:[r&&(0,le.jsx)(N.ActionButton,{onClick:d,label:i("visitUrl")}),(0,le.jsx)(N.ActionButton,{primary:!0,onClick:u,label:i("preview")}),(0,le.jsx)(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},gp=of;var ao=require("react/jsx-runtime"),sf=({contentType:t,lines:e,suggestions:n})=>{let o=he(),s=(0,fp.useSelector)(en),r=a=>{o.send(jr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{o.send(Ue,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,ao.jsx)(ao.Fragment,{children:n.map(a=>(0,ao.jsx)(gp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},hp=sf;var _i={};j(_i,{enUS:()=>rf,nlNL:()=>af});var rf={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"}]},af={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 yp={root:"_root_1bwme_1",loginText:"_loginText_1bwme_7",stateText:"_stateText_1bwme_8",sectionList:"_sectionList_1bwme_20",shortcutList:"_shortcutList_1bwme_24",shortcut:"_shortcut_1bwme_24",link:"_link_1bwme_50"};var Pi=require("react/jsx-runtime"),Sp=()=>(0,Pi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Pi.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 ki=require("react/jsx-runtime"),vp=()=>(0,ki.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ki.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"),Gs=(t,e)=>{let n=(0,z.useSelector)(Ke);(0,Cp.useEffect)(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},lf=()=>{let t=_(_i),e=(0,z.useDispatch)(),n=T("isEmbedded"),o=y("Widget",yp),s=T("showAutoflows"),r=T("showCustomMessages"),i=T("showPersonalCollectionLink"),a=T("showSummaryCommand"),l=T("showKnowledgeSearch"),c=T("showSearch"),u=(0,z.useSelector)(cn),d=(0,z.useSelector)(Es),p=(0,z.useSelector)(Au),g=(0,z.useSelector)(Cs),h=(0,z.useSelector)(Hu),m=(0,z.useSelector)(Ko),x=(0,z.useSelector)(Uo),b=(0,z.useSelector)(Ke),f=(0,z.useSelector)(Bo),v=(0,z.useSelector)(Xu),C=(0,z.useSelector)(en),k=he(),w=(0,z.useSelector)(Nl),D=(0,z.useSelector)(qu("/admin/personal-collection")),ne=T("adminUrl");if(Gs(()=>(e(so(f)),e(Vu(f)),()=>{e(ju(f))}),[e,x,r,f]),Gs(()=>(e(Ze(f)),e(Mu(f)),()=>{e(Ou(f))}),[e,x,s,f]),Gs(()=>{d.forEach(({type:I})=>{e(I==="entities"?Pe():Fe(I))})},[e,x,m,u]),Gs(()=>(e(Si()),()=>{e(Gu())}),[e,x,i,m]),x===!1)return(0,R.jsx)("div",{className:o.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(b===!1)return(0,R.jsx)("div",{className:o.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Ps,{isEmbedded:n,loginUrl:ne})})},"login");if(!u||!f||b===null||w||v)return(0,R.jsx)("div",{className:o.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,xp.default)(o.root),"data-testid":"widget",children:(0,R.jsxs)(Ho,{className:o.sectionList,children:[B&&(0,R.jsx)(ot,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:o.shortcutList,children:[c&&(0,R.jsxs)("button",{className:o.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(Jt,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:o.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(vp,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:o.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[(0,R.jsx)(Sp,{}),t("linkKnowledgeSearch")]}),D&&(0,R.jsxs)("a",{className:o.shortcut,target:"_blank",href:D,rel:"noreferrer",children:[(0,R.jsx)(dp,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&(0,R.jsx)(ot,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(Re,{withDivider:!0,children:h.map(I=>(0,R.jsx)(pp,{suggestion:I},I.text))})}),s&&p.length>0&&(0,R.jsx)(ot,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(Re,{withDivider:!0,children:(0,R.jsx)(ip,{})})}),d.map(({type:I,title:ve,amount:xe,lines:tr})=>{var vt;switch(I){case"entities":return g&&g.length>0&&(0,R.jsx)(ot,{type:I,title:ve,"data-testid":`type-${I}`,children:(0,R.jsx)(cp,{entities:g})},I);default:return((vt=C[I])==null?void 0:vt.fetchState)==="done"&&C[I].suggestions.length>0&&(0,R.jsx)(ot,{type:I,title:ve,"data-testid":`type-${I}`,children:(0,R.jsx)(Re,{withDivider:!0,children:(0,R.jsx)(hp,{lines:tr,contentType:I,suggestions:C[I].suggestions.slice(0,xe)||[]})})},I)}})]})})},Tp=lf;function wp(t){let e=new Range;return e.selectNodeContents(t),e}var lo=/[\u200B-\u200D\uFEFF]/g;function At(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let s=0,r=!1;function i(l,c){let u=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let p=0;p<=l.length;p++)if(d.test(l[p])||u++,u===c)return p;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,d=u.replace(lo,""),p=s+d.length,g=e>=s&&e<=p,h=n>=s&&n<=p;if(g){let m=i(u,e-s);m===0&&!h?o.setStartBefore(l):o.setStart(l,m)}h&&(o.setEnd(l,i(u,n-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(l.tagName==="BR"&&(s===e&&o.setStartBefore(l),s++,s===n)){o.setEndAfter(l),r=!0;return}for(let d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);let u=(c=l.lastChild)==null?void 0:c.tagName;l.tagName==="DIV"&&u!=="DIV"&&u!=="BR"&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function $s(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r}=e,i,a,l=0;function c(u){let d=u===n,p=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;d&&(i=l+g.substring(0,o).replace(lo,"").length),p&&(a=l+g.substring(0,r).replace(lo,"").length),l+=g.replace(lo,"").length;break}case Node.ELEMENT_NODE:{let{tagName:g}=u,h=u.nextSibling===null;g==="BR"&&!h&&l++;for(let m=0;m<u.childNodes.length&&(d&&m===o&&(i=l),c(u.childNodes[m]),p&&m===r-1&&(a=l),a===void 0);m++);!p&&g==="DIV"&&!h&&l++,p&&(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 co(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let u=c===n,d=c===s;switch(u&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let p=u?o:0,g=d?r:void 0,h=c.textContent.replace(lo,"");p===0&&g===void 0?a+=h:a+=h.substring(p,g);break}case Node.ELEMENT_NODE:{let{tagName:p}=c,g=c.nextSibling===null;i===0&&p==="BR"&&!g&&(a+=`
4
- `);for(let h=u?o:0;h<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[h]),i!==1);h++);!d&&i===0&&p==="DIV"&&!g&&(a+=`
5
- `);break}default:break}d&&i++}return l(t),a}var Mt=class extends Ne{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),co(this.element,e)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let e=window.getSelection();if(!e||e.rangeCount===0)return null;let n=e.getRangeAt(0);return!n||!this.element.contains(n.commonAncestorContainer)?null:$s(this.element,n)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:n}=this.currentSelection;return co(this.element,At(this.element,e,n))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),o=e(this.element);(s=this.observer)==null||s.takeRecords(),Promise.resolve(o).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=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 Ri=class{constructor(e){this.name=e;P.warn("BroadcastChannel is not supported")}postMessage(){}addEventListener(){}removeEventListener(){}close(){}},Ii=class{constructor(e,n){this.name=e;this.options=n;this.broadcastChannel=new this.options.broadcastChannelConstructor(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()}},Li=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,n=document.getElementById(e);if(n)return n;let o=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"),o.style.position="absolute",o.style.left="-999em",o.style.width="0px",o.style.height="0px",o.tabIndex=-1,o.id=e,o.title=`iframe-${this.name}`,o.src=`${s}?${r.toString()}`,o}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},Ai=class{sessionId;deepdeskUrl;channel;broadcastChannelConstructor;eventMap;isIntegration;constructor(e){this.deepdeskUrl=e.deepdeskUrl,this.broadcastChannelConstructor=e.broadcastChannelConstructor||window.BroadcastChannel||Ri,this.isIntegration=e.deepdeskUrl!==(e.origin||window.location.origin),this.eventMap=e.eventMap,this.setSessionId("deepdesk-general")}setSessionId(e){if(this.sessionId===e)return;this.cleanup(),P.info("Set sessionId",e),this.sessionId=e,this.channel=this.isIntegration?new Li(e,this.deepdeskUrl,{debug:!0}):new Ii(e,{broadcastChannelConstructor:this.broadcastChannelConstructor});let n=o=>{var s,r;o.origin===this.deepdeskUrl&&o.data.type==="event"&&(P.info("Received broadcast event",this.sessionId,o),(r=(s=this.eventMap)[o.data.name])==null||r.call(s,o.data.payload))};this.channel.onMessage(n)}send(e,n){var s,r,i;if(!this.sessionId)return;P.info("broadcast event",{sessionId:this.sessionId,name:e,payload:n});let o={type:"event",name:e,payload:n};(r=(s=this.eventMap)[e])==null||r.call(s,n),(i=this.channel)==null||i.postMessage(o)}cleanup(){var e;(e=this.channel)==null||e.close(),delete this.channel}},bp=Ai;var yn=class extends Error{constructor(n,o){super(n);this.body=o}name="CustomError"};var Mi=t=>new Promise(e=>{setTimeout(e,t)});var Sn=class extends yn{name="ClientError"},Oi=class extends yn{name="ServerError"},Ye=class t{constructor(e="",n={}){this.baseUrl=e;this.options=n;n.fetch&&(this.fetch=n.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}async request(e,n={}){let o={isStale:!1},s=`${this.baseUrl}${e}`,r=this.fetch,{abortLatest:i=!1,attempts:a=1,retryDelay:l=500,refreshTokenOn401:c=!0,retryOnError:u=C=>C instanceof TypeError,retryOnResponse:d=C=>C.status>=500,version:p="v1",...g}=n,h={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof p=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":p});let m=a,x=!1;if(!r)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&i&&(this.latestRequestByUrl[s].isStale=!0),this.latestRequestByUrl[s]=o;let b=async()=>(m--,r(s,h).then(async C=>d(C)&&!o.isStale&&m>0?(await Mi(l),b()):C.status===401&&c===!0&&x===!1?(x=!0,await this.refreshToken(),b()):C).catch(async C=>{if(u(C)&&!o.isStale&&m>0)return await Mi(l),b();throw C})),f=await b(),v=await f.json().catch(()=>null);if(o.isStale)throw new Error("Aborted");if(f.status>=500)throw new Oi("Server Error",v);if(f.status===401)throw new Sn("Unauthorized",v);if(f.status===403)throw new Sn("Forbidden",v);if(f.status===404)throw new Sn("Not Found",v);if(f.status>=400)throw new Sn("Bad Request",v);return delete this.latestRequestByUrl[s],v}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:n}=await this.get("/apis/admin/session/validate/",{version:null});return!!n}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,{method:"POST",body:JSON.stringify(n),...o})}patch(e,n,o){return this.request(e,{method:"PATCH",body:JSON.stringify(n),...o})}put(e,n,o){return this.request(e,{method:"PUT",body:JSON.stringify(n),...o})}delete(e,n){return this.request(e,{method:"DELETE",...n})}};var cf;(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||={})})(cf||={});function Xs(t){return{...O(t),tags:t.tags}}var et=class t{constructor(e,n={}){this.options=n;this.client=new Ye(e,{fetch:n.fetch}),this.client.patchFetch(o=>async(s,r)=>{let i=await o(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 n=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return Xs(n)}async getProfile(e){let n=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return O(n)}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:n}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return n}async getConversationBySessionId(e,n={}){await this.preflight(),P.info(`Getting conversation for session ${e}`);let{attempts:o=1,retryDelay:s=1e3}=n,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:o,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return Xs(r)}async isConversationSupported(e,n={}){P.info(`Check if conversation for session ${e} is supported`);let{attempts:o=1,retryDelay:s=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:o,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,n){let o=U(n);n.tags&&(o.tags=n.tags);let s=await this.client.put(`/api/conversations/${e}`,o,{version:"v2"});return Xs(s)}async postMessages(e,n){return(await this.client.post(`/api/conversations/${e}/messages`,n.map(s=>({...U(s),tags:s.tags})),{version:"v2"})).map(s=>Xs(s))}async sendEvent(e,n){let{data:o,...s}=n,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",U({...r,...s,data:o,name:e}),{version:"v2"})}async sendEventV1(e,n){let o=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:U({...n,...o})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(o=>o.text)})).entities}async getSummary(e){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(o=>o.text&&o.source)}})).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(n=>{throw P.warn(`Invalid token '${e}'`),n})}async authenticateWithKey(e,n){await this.client.post("/apis/admin/session/api-key/",U(n),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,n={},o){return o==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${o}`,U(n),{abortLatest:!0})).map(r=>({...O(r),text:r.text||r.url||r.message,source:o,type:o})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,n){return(await this.client.post(`/api/conversations/${e}/autocomplete`,U(n),{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 n=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return O(n).map(o=>({...o,text:o.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let n=await this.client.post("/api/style-suggestions",U(e),{abortLatest:!0});return O(n)}async search(e){let n=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return O(n)}async knowledgeSearch(e,n,o){let s=await this.client.post("/api/knowledge-search/search",U({question:e.question,promptInstruction:e.promptInstruction,profile:o,chatHistory:n.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return O(s)}async requestLoginByEmail(e){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return O(n)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let n=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return O(n)}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(Sa);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&P.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};var uo=class{constructor(e,n){this.url=e;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Dr(e),n=>{let{data:o}=n;try{let s=JSON.parse(o);this.emit(e,O(s))}catch{P.warn(`Invalid JSON for ${e}: ${o}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let n=!1;e.onopen=()=>{n=!0},e.onerror=()=>{n&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(o=>{this.proxyEvent(o)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,n){this.eventListeners[e]&&this.eventListeners[e].forEach(o=>o(n))}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),this.proxyEvent(e),()=>{this.off(e,n)}}off(e,n){let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}};var uf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(uf||={});var po=class{constructor(e,n={}){this.apiUrl=e;this.client=new Ye(e,n)}client;streams={};logger=P;async getCustomMessages(e){let n=await this.client.get(`/sessions/${e}/suggestions`);return O(n.suggestions)}async sendCustomMessage(e,n){let o=await this.client.post(`/sessions/${e}/messages`,U(n));return O(o)}async answerCustomMessage(e,n){await this.client.post(`/sessions/${e}/answers`,U(n))}async getAutoflows(e){let n=await this.client.get(`/sessions/${e}/autoflows`);return O(n.autoflows)}async startAutoflowSession(e){let n=await this.client.post("/autoflow-sessions",U(e));return O(n)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new uo(`${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 Js=require("@reduxjs/toolkit");var _p=require("@reduxjs/toolkit");var Ep={startTime:null,stopTime:null},Pp=(0,_p.createSlice)({name:"handlingTime",initialState:Ep,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(L,()=>Ep)}}),{handlingTimeStart:kp,handlingTimeStop:Qs,handlingTimeReset:Rp}=Pp.actions,Ip=Pp.reducer;var Lp=(t={})=>{let e={onAuthError:hs(!1),...t};return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};var Zs=require("@reduxjs/toolkit");var Ni={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Ot=(0,Zs.createAsyncThunk)("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:n}=e.extra,o=e.getState(),{showStyleSuggestions:s}=o.settings,r=(i=o.conversation.current)==null?void 0:i.profileCode;if(!s)return Ni.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:r,message:t})}),pf=(0,Zs.createSlice)({name:"styleSuggestions",initialState:Ni,reducers:{},extraReducers:t=>{t.addCase(Ot.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Ot.rejected,e=>{e.fetchState="error"}).addCase(Ot.fulfilled,(e,n)=>{e.fetchState="done",it(e.list,n.payload)||(e.list=n.payload)}).addCase(L,()=>Ni)}}),Ap=pf.reducer;var Mp=(t={})=>{let e,n=!0,o={getStyleSuggestions:Ot,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!u)return l;let{text:p}=c.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),l}};function df(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Op=(t={})=>{let e={getTextSuggestions:Fe,getAutocompleteSuggestions:Kn,debounce:200,check:_s,...t},n,o=!0;return s=>r=>i=>{var x;let{input:{userCommitted:a}}=s.getState(),l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{recommendTextSuggestions:u,showTabCompletion:d}=c.settings,p=(x=c.conversation.current)==null?void 0:x.id,g=i.type===fs.toString();if(!p||!u&&!d)return l;let{input:{userCommitted:h}}=c;return df(h,a)&&!o&&!g||(clearTimeout(n),!e.check(c))||(n=setTimeout(()=>{o=!1;let b=Ut(c);b===""?s.dispatch(e.getTextSuggestions("default")):s.dispatch(e.getAutocompleteSuggestions(b))},g?0:e.debounce)),l}};var Np=Ot.fulfilled.toString();function mf(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.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||o.push(...i.slice(0,a))}),o}var Dp=t=>e=>n=>o=>{var u;if(o.type!==Np){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(u=r.conversation)==null?void 0:u.current,{agentInfo:l}=r.info;if(s===i)return;let c=mf(s,i);o.type===Np&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:c}})};var gf=(0,Js.combineReducers)({activeSuggestion:Wl,answer:Nc,auth:ac,autoflows:Nu,conversation:_a,contentTypes:vc,customMessages:zu,exchangeToken:$u,entities:wc,handlingTime:Ip,info:Sl,input:Cr.reducer,overlayInput:Z.reducer,settings:Ta,profile:Fc,search:bl,summary:Rc,styleSuggestions:Ap,ui:Jl,textSuggestions:Kl});function Hp(t){return(0,Js.configureStore)({reducer:gf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Lp(),Op({debounce:200}),Mp({debounce:500}),Dp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var ff=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},hf=t=>e=>n=>o=>{var a;let s=e.getState(),r=yr("inlineSuggestions")(s);switch(o.type){case Be.toString():{let l=Ol(o.payload.contentType)(e.getState()),c=l.indexOf(o.payload.suggestion);t.emit("edit-suggestion",{contentType:o.payload.contentType,index:c,suggestions:l});break}case be.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:ff(o.payload.suggestion),...o.payload,replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case $o.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...o.payload,replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case kn.toString():{let l=e.getState(),{text:c,selection:u}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:u},{mayApplyChanges:!0});break}case Jo.toString():t.emit("select-image",o.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case Pe.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:o.payload}});break;case Ve.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{inputText:JSON.stringify(o.payload.original),summary:o.payload.summary}});break;case se.toString():t.sendEvent(o.payload.name,{conversationId:((a=o.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:o.payload.data});break;case Xo.toString():t.handleKeyDown(o.payload);break;case Pn.toString():t.logSendMessage(o.payload);break;case Qo.toString():t.logSendEditSuggestionMessage(o.payload);break;case Zo.toString():t.handleInputChanged(o.payload);break;default:break}let i=n(o);switch(o.type){case Pn.toString():t.handleAfterSendMessage(o.payload);break;case Un.toString():t.onUpdateShowTabHint(o.payload);break;case Qs.toString():t.logHandlingTime();break;case be.toString():{r&&(e.dispatch(lt([])),e.dispatch(ct()));break}default:break}return i},Fp=hf;function Di(t){return t.toISOString().replace("T"," ").replace("Z","")}function Bp(t,e){var s,r,i;let{startTime:n,stopTime:o}=t.handlingTime;if(!n||!o)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:Di(n),timeStop:Di(o)}}function Hi(t,e,n){var k,w,D;let{text:o,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,pastes:u,cuts:d,deletions:p,textSuggestions:g,offeredTextSuggestions:h}}=e[t],m=o.length,b=g.reduce((ne,{text:B,searchTerm:I})=>ne+B.length-(I?I.length:0),0),f=c??Date.now(),v=(Date.now()-f)/1e3,C=s/v;return{conversationId:e.conversation.current.id,source:"agent",text:o,clientVersion:n.version,pastes:u,cuts:d,deletions:p,lenTextTyped:s,lenTextTotal:m,lenTextAssisted:b,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:v,charsPerSecond:C,numPastes:l,textSuggestionsV2:g,suggestionsCounters:[{source:"gpt",countOffered:h.filter(ne=>ne.source==="gpt").length}],agentId:(k=e.info.agentInfo)==null?void 0:k.agentId,agentName:(w=e.info.agentInfo)==null?void 0:w.agentName,agentEmail:(D=e.info.agentInfo)==null?void 0:D.agentEmail}}function Kp(t,e){let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;return o instanceof HTMLElement?Kp(o,e):null}function Up(t,e){return Kp(t,e)}function Vp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Ys(t){return t instanceof HTMLElement&&(Ge(t)||ns(t))}var jp=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch{return e}}catch{return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch{P.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function yf(t){return t.offsetParent!==null}function zp(t){if(!yf(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 er(t,e,n=100){let o=zp(t);e({isVisible:o});let s=setInterval(()=>{let r=zp(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}var ce=require("react/jsx-runtime"),qp=jp("showTabHint",!0),mo=class t{static version="10.1.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:n,version:o=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a}){let l=e.replace(/\/api$/,"");this.deepdeskApi=new et(l,{token:r,fetch:i}),this.version=o,this.instanceId=t.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Fp({emit:(u,d,p)=>this.emit(u,d,p),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=>qp.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new po(n)}),this.store=Hp(c),this.broadcastEvents=new bp({debug:!0,deepdeskUrl:l,eventMap:lc(this.store)}),this.store.dispatch(_n),this.store.dispatch(Un(qp.value())),this.store.dispatch(_n({locale:s,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(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(hs(null)),this.store.dispatch(kt()),new Promise(e=>{let n=this.store.subscribe(()=>{let o=this.store.getState();Ke(o)&&tc(o)!=="loading"&&e()});this.unmountHandlers.push(()=>{n()})})}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(n){P.warn("Failed to attach user:",n)}}async isConversationSupported(e,n){return(await this.store.dispatch(vr({sessionId:e,options:n}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Vo(e))).payload}async getConversationBySessionId(e,n){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(jo({sessionId:e,options:n}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(xr(e))).payload}async postMessages(e){return(await this.store.dispatch(qo(e))).payload}async updateConversation(e){return(await this.store.dispatch(zo(e))).payload}resetConversation(){this.store.dispatch(L()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(Ve());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(_n(e))}setVisitorInfo(e){this.store.dispatch(yl(e))}async setAgentInfo(e){await this.store.dispatch(Dn(e))}async setAgentSettings(e){await this.store.dispatch(Hr(e))}async getAgentSettings(){return(await this.store.dispatch(Fr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(fs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Zo(e))}syncInputHtml(e){this.store.dispatch(Ua(e))}notifyKeyDown(e){this.store.dispatch(Xo(e))}notifyPaste(e,n){this.store.dispatch(Ba({text:e,selectionText:n}))}notifyCut(e){this.store.dispatch(Ha(e))}notifyExternalSuggestion(e){this.store.dispatch(be(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Fl(e.contentType,e.suggestions)),this.store.dispatch(Be({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui;n&&o&&this.store.dispatch(nn({collapse:!1})),this.inputMediator&&this.store.dispatch(La({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(lt([])))}handleKeyDown(e){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=o.length>0,l=s!==-1;if(this.store.dispatch(Fa(Go(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(n||!a||!r||e.shiftKey)return;this.store.dispatch(Oa()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(n||!a||!r||e.shiftKey)return;this.store.dispatch(Da());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(kn()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(Yo(-1)),this.store.dispatch(kn()),e.preventDefault()):n||(this.store.dispatch(nn({collapse:!0})),this.store.dispatch(Ql(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,u=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:d}=this.state.input;this.store.dispatch(Un(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&d&&d.text.startsWith(u)&&(this.store.dispatch(be({text:d.text,suggestion:d,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ct())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ka()),this.store.dispatch(lt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(P.info("Start handling time"),this.store.dispatch(kp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(P.info("Stop handling time"),this.store.dispatch(Qs()))}logSendMessage(e){let n=Hi("input",this.state,{version:this.version});e&&Object.assign(n,{text:e}),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(e){let n=Hi("overlayInput",this.state,{version:"v2"});e&&Object.assign(n,{text:e}),this.store.dispatch(Ma(this.state.overlayInput.metrics)),this.deepdeskApi.sendEvent("suggestion edited",{data:n})}logHandlingTime(){let e=Bp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Rp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(Pn(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:o}=this.state.input;this.store.dispatch(be({text:o[n].text,suggestion:o[n],eventMetrics:e,replace:"until-selection-end"}))}emit(e,n,o={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(n)}catch(i){P.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),P.error(i)}})};this.inputMediator&&o.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let n=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&n();let o=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==o&&(o=this.hasConversation(),o&&n())})}overlayContainerFactory(e,n,o,s){let[r,i]=Xt(o,s);return r.dataset.testid=e,n!=null&&n.rootNode&&r.classList.add(n.rootNode),this.unmountHandlers.push(()=>{(0,tt.unmountComponentAtNode)(r),i(),r.remove()}),r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return bt(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,n.appendChild(s),this.unmountHandlers.push(()=>{(0,tt.unmountComponentAtNode)(s),s.remove()}),s}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Ys(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:o={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:u,isEmbedded:d,detectSubmit:p,insertLink:g,inputMediator:h,closestScrollSelector:m,appendOverlayTo:x,inlineSuggestions:b}=n;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:u,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:b});let f=m&&Up(e,m)||void 0,v=this.overlayContainerFactory("deepdesk-tab-completion",o,e,{appendTo:x,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",o,f||e,{appendTo:x});n.automaticHandlingTime&&this.setupHandlingTime(e),(0,tt.render)((0,ce.jsx)(to,{store:this.store,customStyles:o,children:(0,ce.jsx)(jn,{broadcastEvents:this.broadcastEvents,children:(0,ce.jsx)(Ru,{inputElement:e})})}),v),(0,tt.render)((0,ce.jsx)(to,{store:this.store,customStyles:o,children:(0,ce.jsx)(jn,{broadcastEvents:this.broadcastEvents,children:(0,ce.jsx)(Is,{})})}),C),(0,tt.render)((0,ce.jsx)(to,{store:this.store,customStyles:o,children:(0,ce.jsx)(jn,{broadcastEvents:this.broadcastEvents,children:(0,ce.jsx)(jc,{})})}),this.createContainer("deepdesk-overlays")),bt(e),this.inputMediator=h||(Ge(e)?new De(e):new Mt(e)),this.inputMediator.on("change",({plainText:w})=>{this.notifyInputChanged(w)}),this.inputMediator.on("updated",({rawHtml:w})=>{w!=null&&this.syncInputHtml(w)}),this.inputMediator.on("keydown",w=>{this.notifyKeyDown(w)}),this.inputMediator.on("paste",({pastedText:w,selectionText:D})=>{this.notifyPaste(w,D)}),this.inputMediator.on("cut",({selectionText:w})=>{this.notifyCut(w)});let k;this.inputMediator.on("selection",w=>{clearTimeout(k),w===null?k=setTimeout(()=>{w!==null&&this.store.dispatch(Tr(w))},500):this.store.dispatch(Tr(w))}),this.inputMediator.on("disabled",()=>{var w;(w=this.inputMediator)==null||w.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{p&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(tn(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(tn(!0))),this.store.dispatch(Aa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var w;this.broadcastEvents.setSessionId((w=this.state.conversation.current)==null?void 0:w.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,n={}){if(this.widgetRoot&&P.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=n;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),(0,tt.render)((0,ce.jsx)(to,{store:this.store,customStyles:o,children:(0,ce.jsx)(jn,{broadcastEvents:this.broadcastEvents,children:(0,ce.jsx)(Tp,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,tt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let n=er(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Vp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(Yn());let e=cn(this.state);e&&this.store.dispatch(_n({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeSearch,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.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(n){let{message:o}=n;P.info(o),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=Es(this.state);try{n.forEach(({type:o})=>{o==="entities"?this.store.dispatch(Pe()):this.store.dispatch(Fe(o))})}catch(o){this.handleError(o)}}};async function Wp(t,e,n={}){let{value:o}=t,{start:s,end:r}=n.replace??{start:0,end:o.length},i=`${o.slice(0,s)}${e}${o.slice(r)}`,a=n.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(n.setValue)return n.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function Gp(t,e,n={}){let o=n.replace?At(t,n.replace.start,n.replace.end):wp(t),s,r=()=>{if(n.setRange)return n.setRange(o.cloneRange());o.deleteContents(),s=document.createElement("span"),o.insertNode(s),e.split(`
6
- `).reverse().forEach((i,a)=>{a>0&&o.insertNode(document.createElement("br")),o.insertNode(document.createTextNode(i))}),o.commonAncestorContainer===t&&o.surroundContents(document.createElement("div"))};return Promise.resolve(r()).then(()=>{try{if(n.selectionAfter!==!1){t.focus();let i=n.selectionAfter?At(t,n.selectionAfter.start,n.selectionAfter.end):(o.collapse(!1),o),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 $p(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Xp(t,e,n){await new et(t).authenticateWithKey(e,n)}async function Qp(t){let n=await new Ye(t).get("/platform/config/",{version:null});return O(n)}async function Sf(t){let n=await(t.fetch??window.fetch)(t.url),o=await n.blob();return new File([o],t.name,{type:t.mimeType??n.headers.get("Content-Type")??"image/jpeg"})}async function Zp(t,e){let n=await Sf(e),o=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[n]}),t.dispatchEvent(o)}finally{Object.hasOwn(t,"files")&&delete t.files}}0&&(module.exports={Card,Chip,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});
3
+ `,Ct.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));v=p.options[x]||p.options.other}if(!v)throw new pr(p.value,u,Object.keys(p.options),i);a.push.apply(a,To(v.value,e,o,n,s,u-(p.offset||0)));continue}}return wd(a)}function Ed(t,e){return e?re(re(re({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=re(re({},t[n]),e[n]||{}),o},{})):t}function kd(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Ed(t[n],e[n]),o},re({},t)):t}function ur(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Pd(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:An(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,xn([void 0],o,!1)))},{cache:ur(t.number),strategy:Mn.variadic}),getDateTimeFormat:An(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,xn([void 0],o,!1)))},{cache:ur(t.dateTime),strategy:Mn.variadic}),getPluralRules:An(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,xn([void 0],o,!1)))},{cache:ur(t.pluralRules),strategy:Mn.variadic})}}var Ji=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==q.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return To(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Vi(i,["formatters"]);this.ast=t.__parse(e,re(re({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=kd(t.formats,n),this.formatters=s&&s.formatters||Pd(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(!(typeof Intl.Locale>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Gi,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t}();function Id(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Rd="dummy",dr=(0,On.createContext)(null);function E(t){let e=(0,On.useContext)(dr);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=Id(o,n);return r?new Ji(r).format(s):(e!==Rd&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var mr={};j(mr,{enUS:()=>Ld,nlNL:()=>Ad});var Ld={experimental:[{type:0,value:"Experimental"}]},Ad={experimental:[{type:0,value:"Experimenteel"}]};var gr=require("react/jsx-runtime"),Yi=({children:t})=>{let e=y("Chip",ji);return(0,gr.jsx)("span",{className:e.root,children:t})},Nn=()=>{let t=E(mr);return(0,gr.jsx)(Yi,{children:t("experimental")})},ea=Yi;var oa=T(require("classnames"));var ta={root:"_root_cq1yq_1"};var na=require("react/jsx-runtime");var Md={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},Od=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ta);return(0,na.jsx)("span",{"data-key":Md[e],className:(0,oa.default)(t,n.root),...o})},Dn=Od;var ra=T(require("classnames"));var sa={root:"_root_4a08n_1"};var ia=require("react/jsx-runtime"),Nd=({className:t,children:e,...o})=>{let n=y("Label",sa);return(0,ia.jsx)("span",{...o,className:(0,ra.default)(t,n.root),children:e})},Bn=Nd;var aa={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var Bt=require("react/jsx-runtime"),Dd=({title:t,children:e,type:o,...n})=>{let s=y("Section",aa);return(0,Bt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,Bt.jsx)("div",{className:s.subTitleContainer,children:(0,Bt.jsx)("span",{className:s.subtitle,children:t})}),(0,Bt.jsx)("div",{className:s.suggestions,children:e})]})},nt=Dd;var ca=T(require("classnames")),pa=T(require("react"));var la={root:"_root_19wxp_1"};var ua=require("react/jsx-runtime"),Bd=pa.default.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",la);return(0,ua.jsx)("div",{ref:o,className:(0,ca.default)(n.root,t),children:e})}),Hn=Bd;var Eo=T(require("classnames")),me=T(require("react"));var fr={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 de=require("react/jsx-runtime"),Ht=(0,me.createContext)(fr),Hd=({fixed:t,children:e,...o})=>{let n=(0,me.useContext)(Ht);return(0,de.jsx)("div",{...o,className:(0,Eo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Fd=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,me.useContext)(Ht);return(0,de.jsxs)("div",{className:(0,Eo.default)(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,(0,de.jsx)("ul",{className:r.dropdownList,children:s})]})},Kd=({index:t,label:e,onClick:o})=>{let n=(0,me.useContext)(Ht);return(0,de.jsx)("li",{className:n.dropdownItem,children:(0,de.jsx)("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Ud=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,me.useContext)(Ht);return(0,de.jsx)("button",{type:"button",className:(0,Eo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},hr=({labels:t})=>{let e=(0,me.useContext)(Ht);return(0,de.jsx)("div",{className:e.labels,children:t.map(o=>(0,de.jsx)("span",{className:e.label,children:o},o))})},Ft=me.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",fr),l=(0,me.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,de.jsx)(s,{...r,ref:i,className:(0,Eo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,de.jsx)(Ht.Provider,{value:a,children:n})})});Ft.Labels=hr;Ft.Actions=Hd;Ft.ActionButton=Ud;Ft.DropdownButton=Fd;Ft.DropdownItem=Kd;var N=Ft;var ma=T(require("classnames"));var da={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var ga=require("react/jsx-runtime"),zd=({withDivider:t,children:e})=>{let o=y("SuggestionList",da);return(0,ga.jsx)("div",{className:(0,ma.default)(o.root,{[o.isWithDivider]:t}),children:e})},Ie=zd;var ha=T(require("classnames"));var fa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var Fn=require("react/jsx-runtime"),jd=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",fa);return(0,Fn.jsx)("button",{type:"button",className:(0,ha.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,Fn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,Fn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},wt=jd;var ya=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Kt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var Sa=/x-deepdesk-(([a-z0-9\-_])+-version)/,st=(u=>(u.SEARCH="search",u.TEMPLATE="template",u.ELASTIC_SEARCH="studio-search",u.GPT="gpt",u.TRIE="trie",u.TRIE_WITH_TYPOS="trie-with-typos",u.SEMANTIC="semantic",u.TEXT_RECOMMENDATION="text_recommendation",u.URL_RECOMMENDATION="url_recommendation",u.LINK_RECOMMENDATION="link_recommendation",u.PERSONAL_COLLECTION="personal-collection",u.PERSONAL_COLLECTION_SEARCH="personal-collection-search",u))(st||{}),rt=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(rt||{});var tt=require("react-dom");var jc=require("react");var va=require("@reduxjs/toolkit"),_a=require("react-redux");var ko=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(ko||{});var Vd={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,adminUrl:void 0,productName:"Deepdesk"},xa=(0,va.createSlice)({name:"settings",initialState:Vd,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Po}=xa.actions,yr=t=>e=>e.settings[t],b=t=>(0,_a.useSelector)(yr(t)),ba=xa.reducer;var cc=require("react"),io=require("react-redux");var Re=require("@reduxjs/toolkit"),ka=require("diff"),Pa=require("react-redux");function Ca(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function it(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>it(r,e[i],o-1)):Ca(t)&&Ca(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>it(t[i],e[i],o-1)):!1}function qd(t){return Math.max(...t.map(e=>e.length))}function Wd(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function wa(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<qd(n);s++){let r=Wd(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Gd=2;function Sr(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=wa(t,Gd);return o&&o.text!==e?o:t[0]}var Ce=require("@reduxjs/toolkit"),Ta={current:null,isSupported:null},R=(0,Ce.createAction)("resetConversation"),Kn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Un=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},zn=t=>t.conversation.isSupported,vr=(0,Ce.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),jn=(0,Ce.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Vn=(0,Ce.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),qn=(0,Ce.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Un(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),_r=(0,Ce.createAsyncThunk)("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Wn=(0,Ce.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Un(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),$d=[jn.rejected,Vn.rejected,qn.rejected,Wn.rejected].map(t=>t==null?void 0:t.toString()),Xd=(0,Ce.createSlice)({name:"conversation",initialState:Ta,reducers:{},extraReducers:t=>{t.addCase(vr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(jn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Vn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(_r.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(qn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Wn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(R,()=>Ta).addMatcher(e=>$d.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),Ea=Xd.reducer;var at={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function $n(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 Xn=(0,Re.createAction)("input/replaceText"),Qn=(0,Re.createAction)("input/keyDown"),Io=(0,Re.createAction)("input/sendMessage"),Zn=(0,Re.createAction)("input/sendEditSuggestionMessage"),Jn=(0,Re.createAction)("input/uiInputChange"),Yn=(0,Re.createAction)("input/applyImageSuggestion"),ie=(0,Re.createAction)("input/sendEvent");function Gn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i},eventMetrics:{inputType:a},replace:l}=t.stagedSuggestion,c=o==="search"||o==="personal-collection-search",p=c||l==="selection"?e:e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:p,source:o,abVariant:n,abTestName:s,inputType:a,sourceText:i,trainingJobs:r||[],searchTerm:c?t.userCommitted.text:null}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Ia=t=>(0,Re.createSlice)({name:t,initialState:at,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...at,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Sr(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,o){e.html=o.payload},changeSelection(e,o){o.payload&&(it(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Gn(e)))},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:h}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:_}=o.payload,w=(0,ka.diffChars)(m,_);m.length-_.length>1&&e.metrics.deletions.push(...w.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=m.length-_.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!u&&!g&&!h){e.metrics.numCharsTyped+=1;let m=((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;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=at.metrics,e.textSuggestions=[]),e.text!==o.payload.text&&Gn(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"&&Gn(e)},commitSuggestion(e){Gn(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=Sr(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}){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(R,o=>{o.tabCompletionSuggestion=at.tabCompletionSuggestion,o.previousKeyDownEvent=at.previousKeyDownEvent,o.textSuggestions=at.textSuggestions,o.selectedSuggestionIndex=at.selectedSuggestionIndex,o.metrics=at.metrics})}}),xr=Ia("input"),Ut=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),Qd=t=>t.input.selection,Ra=()=>(0,Pa.useSelector)(Qd),{userInput:La,changeSelection:br,initialInput:Aa,mergeMetrics:Ma,nextTextSuggestionIndex:Oa,offeredTextSuggestion:Na,previousTextSuggestionIndex:Da,registerCut:Ba,registerKeyDown:Ha,registerPaste:Fa,reset:Ka,resetToCommitted:Ro,setInputHtml:Ua,setSelectedTextSuggestionIndex:es,setTextSuggestions:lt,stageSuggestion:we,commitSuggestion:ct}=xr.actions,Z=Ia("overlay");var zt=require("react");var za={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Cr=require("react/jsx-runtime"),Zd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,zt.useRef)(null),l=(0,zt.useRef)(null),c=y("Dialog",za);return(0,zt.useEffect)(()=>{var u,g;let p=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},d=h=>{let m=window.getSelection();m!=null&&m.toString()||h.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var h,m;(h=a.current)==null||h.removeEventListener("click",d),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),(0,zt.useEffect)(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?(0,Cr.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Cr.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},jt=Zd;var Kr=require("react"),gs=require("react-redux");var wr={};j(wr,{enUS:()=>Jd,nlNL:()=>Yd});var Jd={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},Yd={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ja={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};var Lo=require("react/jsx-runtime"),ts=()=>(0,Lo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Lo.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Lo.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 Ao=require("react/jsx-runtime"),Va=()=>(0,Ao.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Ao.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Ao.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 fe=require("react"),il=require("react-redux"),al=require("interweave"),Ar=T(require("classnames"));var Tr={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};var Wa=require("interweave"),Ga=T(require("classnames"));var Vt=require("react");function qa(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function os(t){let e=(0,Vt.useRef)(null),[o,n]=(0,Vt.useState)(!1);return(0,Vt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=qa((p,d)=>{let u=e.current;if(!u)return;let g=p/r,h=d/r,m=u.getBoundingClientRect(),_=g>m.x&&g<m.x+m.width&&h>m.y&&h<m.y+m.height;_&&!s?(s=!0,n(!0)):!_&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=qa(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var ge={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var Er=require("react/jsx-runtime"),em=({inputElement:t,children:e})=>{let o=y("TabCompletion",ge),[n,s]=os(t);return(0,Er.jsx)("mark",{ref:n,className:(0,Ga.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},qt=class extends Wa.Matcher{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return(0,Er.jsx)(em,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Wt=require("react");function ns(t){return t.contentEditable==="true"}function tm(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function $a(t){let{selectionStart:e,selectionEnd:o}=ns(t)?tm(t):t;return[e,o]}function ss(t){let[,e]=(0,Wt.useState)(),o=(0,Wt.useRef)(null);return o.current=$a(t),(0,Wt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=$a(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function rs(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Kt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var Xa=require("react");function Gt(t){(0,Xa.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Tt(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Qa,Le=new Map,om=["bottom","height","left","right","top","width"],nm=(t={},e={})=>om.some(o=>t[o]!==e[o]),Za=()=>{let t=[];Le.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Le.delete(o);return}let n=o.getBoundingClientRect();nm(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),Le.size!==0&&(Qa=window.requestAnimationFrame(Za))};function Ja(t,e){return{observe(){let o=Le.size===0;if(Le.has(t)){let n=Le.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Le.set(t,{rect:void 0,callbacks:[e]});o&&Za()},unobserve(){let o=Le.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Le.delete(t),Le.size||cancelAnimationFrame(Qa)}}}}var Ya,Ae=new Map,el=()=>{Ae.forEach((t,e)=>{if(!e.isConnected){Ae.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)))}),Ae.size!==0&&(Ya=window.requestAnimationFrame(el))};function tl(t,e){return{observe(){let o=Ae.size===0;Ae.has(t)?Ae.get(t).callbacks.push(e):Ae.set(t,{visible:void 0,callbacks:[e]}),o&&el()},unobserve(){let o=Ae.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ae.delete(t),Ae.size||cancelAnimationFrame(Ya)}}}}var kr=["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 Pr(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function $t(t){return parseFloat(t)}function is(t){return Math.round(t*1e6)}function ol(t){return t/1e6}function Ir(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=$t(t.width),r=$t(t.borderLeftWidth),i=$t(t.borderRightWidth),a=$t(t.paddingRight),l=ol(is(s)-is(r)-is(i)),c=ol(is(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Xt(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",Tt(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Pr(n,o,kr),Ir(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=tl(t,()=>{Pr(n,o,kr),Ir(n,t,o),r(),setTimeout(r,0)}),a=Ja(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(Pr(n,o,kr),Ir(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(),d=window.getComputedStyle(e.closestScrollElement),u=$t(d.borderTopWidth),g=$t(d.borderBottomWidth),h=p.top+u-c.top,m=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${h}px 0px ${m}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 Rr={};j(Rr,{enUS:()=>sm,nlNL:()=>rm});var sm={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"}]},rm={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 Mo=require("react/jsx-runtime"),nl=()=>(0,Mo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Mo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Mo.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 Lr=require("react/jsx-runtime"),sl=()=>(0,Lr.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Lr.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var rl=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(rl||{}),Ne=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e,rawHtml:o}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e,rawHtml:o}),this.currentHTML=o))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(rl).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){let e=this.currentSelection;this.isPossibleClearInputAction=!0,e&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){let o=(e.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){let e=()=>{let n=document.activeElement===this.element?this.getSelection():null;it(this.currentSelection,n)||(this.currentSelection=n,this.emit("selection",n))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let o=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});o.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{o.disconnect()})}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var De=class extends Ne{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var J=require("react/jsx-runtime"),im=({value:t,onUse:e,...o})=>{var p;let n=E(Rr),s=(0,il.useDispatch)(),r=y("EditSuggestionTextInput",Tr),[i,a]=(0,fe.useState)(null),l=(0,fe.useRef)(null),c=((p=t.match(Kt))==null?void 0:p.length)||0;return(0,fe.useEffect)(()=>{let d;return l.current&&(a(l.current),d=new De(l.current),d.on("change",({plainText:u})=>{s(Z.actions.userInput({text:u,selection:d.getSelection()}))}),d.on("keydown",u=>{s(Z.actions.registerKeyDown($n(u))),u.code==="Enter"&&u.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:u,selectionText:g})=>{s(Z.actions.registerPaste({text:u,selectionText:g}))}),d.on("cut",({selectionText:u})=>{s(Z.actions.registerCut(u))})),()=>{s(Z.actions.reset()),d.dispose(),d.deactivate()}},[l]),(0,fe.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,fe.useEffect)(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let d=l.current.value.length;l.current.setSelectionRange(d,d),l.current.focus()},0)},[l]),(0,J.jsxs)("div",{className:r.textInputWrapper,children:[(0,J.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,J.jsx)(am,{inputElement:l.current,value:t}),(0,J.jsxs)("div",{className:(0,Ar.default)(r.alert,c===0?r.success:r.warning),children:[(0,J.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,J.jsx)(nl,{}):(0,J.jsx)(sl,{})]})]})},am=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",Tr),n=(0,fe.useRef)(null),s=ss(t);return(0,fe.useEffect)(()=>{rs(t,s)},[s,t]),(0,J.jsx)(lm,{inputElement:t,children:(0,J.jsxs)("div",{ref:n,className:(0,Ar.default)(o.root,o.agentText),children:[(0,J.jsx)(al.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new qt("placeholders")],inputElement:t,boundaryRef:n}),(0,J.jsx)("br",{})]})})},lm=({inputElement:t,children:e})=>{let o=(0,fe.useRef)(null);return(0,fe.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Xt(t,{overlayContainer:o.current,mirrorOverflow:!0});return()=>{s()}},[o.current]),(0,J.jsx)("div",{ref:o,children:e})},ll=im;var Yt=require("react");var Y={root:"_root_m5usm_1",list:"_list_m5usm_2",listWrapper:"_listWrapper_m5usm_6",listHorizontal:"_listHorizontal_m5usm_10",page:"_page_m5usm_19",search:"_search_m5usm_25",pageNav:"_pageNav_m5usm_33",pageTitle:"_pageTitle_m5usm_41",pageBackButton:"_pageBackButton_m5usm_48",listHeading:"_listHeading_m5usm_62",listItem:"_listItem_m5usm_70",listItemContent:"_listItemContent_m5usm_79",listItemText:"_listItemText_m5usm_97",listItemDescription:"_listItemDescription_m5usm_105",truncate:"_truncate_m5usm_112",lineClamp:"_lineClamp_m5usm_118",listItemTitle:"_listItemTitle_m5usm_125",listItemAction:"_listItemAction_m5usm_132",listItemPrimaryAction:"_listItemPrimaryAction_m5usm_146",listItemSelected:"_listItemSelected_m5usm_151",sources:"_sources_m5usm_155",sourcesTitle:"_sourcesTitle_m5usm_162",source:"_source_m5usm_155",icon:"_icon_m5usm_177",searchIcon:"_searchIcon_m5usm_194",searchInputWrapper:"_searchInputWrapper_m5usm_199",searchInput:"_searchInput_m5usm_199",select:"_select_m5usm_220",selectType:"_selectType_m5usm_237",selectWrapper:"_selectWrapper_m5usm_241",image:"_image_m5usm_271",imageSrc:"_imageSrc_m5usm_278",imageTitle:"_imageTitle_m5usm_289",actions:"_actions_m5usm_294",actionsWrapper:"_actionsWrapper_m5usm_298",actionsBar:"_actionsBar_m5usm_304",actionButton:"_actionButton_m5usm_313",actionShortcut:"_actionShortcut_m5usm_331",actionShortcutFixKerning:"_actionShortcutFixKerning_m5usm_338"};var Oo=require("react/jsx-runtime"),cm=({src:t,title:e})=>{let o=y("CommandPalette",Y);return(0,Oo.jsxs)("div",{className:o.image,children:[(0,Oo.jsx)("img",{src:t,alt:e,className:o.imageSrc}),e&&(0,Oo.jsx)("span",{className:o.imageTitle,children:e})]})},cl=cm;var pl=T(require("react")),ul=T(require("classnames"));var No=require("react/jsx-runtime");function Mr({children:t,heading:e,orientation:o}){let n=y("CommandPalette",Y);return pl.default.Children.count(t)===0?null:(0,No.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,No.jsx)("h4",{className:n.listHeading,children:e}),(0,No.jsx)("div",{className:(0,ul.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Do=T(require("classnames"));var as=T(require("react")),gl=require("react/jsx-runtime"),dl=as.default.createContext(void 0);function pt(){let t=as.default.useContext(dl);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ml=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=as.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,gl.jsx)(dl.Provider,{value:i,children:t})};var he=require("react/jsx-runtime");function Or({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...p}){let{selected:d,onChangeOpen:u}=pt(),g=y("CommandPalette",Y);function h(m){n(m),t&&u(!1)}return(0,he.jsxs)("div",{className:(0,Do.default)(g.listItem,d===r&&g.listItemSelected),children:[(0,he.jsxs)("button",{type:"button",className:(0,Do.default)("command-palette-list-item",g.listItemAction,g.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,...p,children:[(0,he.jsxs)("div",{className:g.listItemContent,children:[typeof o=="string"?(0,he.jsx)("p",{className:(0,Do.default)(g.listItemText,g.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,he.jsx)("p",{className:(0,Do.default)(g.listItemDescription,c==null?void 0:c.description,e?g.lineClamp:g.truncate),children:a})]}),i&&(0,he.jsx)(Nn,{})]}),l&&(0,he.jsxs)("div",{className:g.sources,children:[(0,he.jsx)("span",{className:g.sourcesTitle,children:"Sources"}),l.map(m=>m.url?(0,he.jsx)("a",{className:g.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>s&&s(m),children:m.name},m.url):(0,he.jsx)("span",{className:g.source,children:m.name},m.name))]})]})}var Bo={};j(Bo,{enUS:()=>pm,nlNL:()=>um});var pm={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}]},um={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}]};var ut=require("react/jsx-runtime");function Nr({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=E(Bo),i=y("CommandPalette",Y),{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)(ts,{}),r("back")]}),e&&(0,ut.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,ut.jsx)(Nn,{})]}),t]})}var dt=require("react");var ls=()=>/Mac/i.test(navigator.platform);var ps=require("@reduxjs/toolkit");var dm={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=dm;var Qt=require("@reduxjs/toolkit");function mm(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,[mm(o)]:O(t[o])}),{}):t}function Dr(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function U(t){return Array.isArray(t)?t.map(U):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Dr(o)]:U(t[o])}),{}):t}var gm={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Fo=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},Ho=(0,Qt.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))}),Br=(0,Qt.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}),Hr=(0,Qt.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),fl=t=>t.info.agentInfo,hl=(0,Qt.createSlice)({name:"info",initialState:gm,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(Ho.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(Ho.rejected,e=>{e.fetchState="error"}).addCase(Ho.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(Br.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Hr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(R,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:yl}=hl.actions,Sl=hl.reducer;var cs={list:[],fetchState:"idle",isOpen:!1,page:"search"},vl=t=>t.search.isOpen,_l=t=>t.search.page,xl=t=>t.search.list;function bl(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Et=(0,ps.createAsyncThunk)("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Fo(n),tags:t.tags});return r}),Cl=(0,ps.createSlice)({name:"search",initialState:cs,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=cs.fetchState,t.list=cs.list}},extraReducers:t=>{t.addCase(Et.pending,e=>{e.fetchState="loading"}).addCase(Et.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Et.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(R,()=>cs)}}),{resetSearch:us,setIsOpen:ae,setPage:$}=Cl.actions,wl=Cl.reducer;var fm=/(https?:\/\/[^\s]+)/,ds=t=>t.split(" ").find(e=>fm.test(e));var Fr=T(require("classnames"));var ms=require("react/jsx-runtime"),hm=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",Y);return(0,ms.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Fr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,ms.jsx)("span",{className:(0,Fr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},Zt=hm;var Be=require("react/jsx-runtime"),ym=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",Y),a=E(Bo),{selected:l,setSelected:c}=pt(),p=r[l],d=p&&typeof p.text=="string"&&ds(p.text),u=(0,dt.useRef)(null);function g(v){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),P=0,C=0;v==="down"?(x.forEach((ne,F)=>{F===l&&(P=F)}),C=P===x.length-1?0:P+1):v==="up"?(x.forEach((ne,F)=>{F===l&&(P=F)}),C=P?P-1:x.length-1):c(0);let D=x[C];D&&typeof C=="number"&&(c(C),D.scrollIntoView&&D.scrollIntoView({behavior:"smooth",block:C?"center":"end"}))}function h(){if(!u.current)return;let v=u.current.querySelectorAll(".command-palette-list-item"),x=0;v.forEach((C,D)=>{D===l&&(x=D)});let P=v[x];P&&P.click()}let m=()=>{d&&window.open(d,"_blank")},_=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},f=(0,dt.useCallback)(v=>{if(v.key==="Enter"&&v.altKey&&d){m();return}if(v.key==="Enter"&&v.shiftKey){w();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),g("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),g("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return(0,dt.useEffect)(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),(0,Be.jsxs)("div",{className:i.actions,children:[(0,Be.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,Be.jsxs)("div",{className:i.actionsBar,children:[d&&(0,Be.jsx)(Zt,{onClick:m,shortKeys:[ls()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,Be.jsxs)(dt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,Be.jsx)(Zt,{onClick:w,shortKeys:[8679,8629],children:o}),(0,Be.jsx)(Zt,{onClick:_,shortKeys:[8629],children:e})]})]})]})},El=ym;var kl=require("react");var Ko=require("react/jsx-runtime"),Jt=()=>(0,Ko.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,Ko.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,Ko.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});var Te=require("react/jsx-runtime");function Sm({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",Y);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(Jt,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.jsx)("input",{ref:a,spellCheck:!1,onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&(0,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Pl=(0,kl.forwardRef)(Sm);var Uo=require("react/jsx-runtime");function kt({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:d,search:u}){let[g,h]=(0,Yt.useState)(0),m=(0,Yt.useRef)(null),_=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var f;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(f=m.current)==null||f.focus();return}if(u.length>0){r("");return}a(!1)};return(0,Yt.useEffect)(()=>{h(0)},[u,n]),(0,Uo.jsx)(jt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:_,children:(0,Uo.jsxs)(ml,{selected:g,setSelected:h,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Uo.jsx)(Pl,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}kt.Page=Nr;kt.List=Mr;kt.Image=cl;kt.ListItem=Or;kt.ActionsBar=El;kt.Button=Zt;var A=kt;var G=require("react/jsx-runtime"),vm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",ja),l=(0,gs.useDispatch)(),c=E(wr),p=(0,gs.useSelector)(h=>h.overlayInput.text);(0,Kr.useEffect)(()=>{t&&(l(Z.actions.reset()),l(Z.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Z.actions.commitSuggestion()))},[t]);let d=h=>{h.preventDefault(),u(p)},u=h=>{l(Zn(h)),e(h)},g=h=>m=>{p!==i?window.confirm(c("warning"))&&h(m):h(m)};return(0,Kr.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,G.jsxs)("div",{className:a.root,children:[(0,G.jsxs)("div",{className:a.content,children:[t.title&&(0,G.jsx)("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&(0,G.jsx)(hr,{labels:t.searchKeywords}),(0,G.jsx)(ll,{onUse:u,value:p})]}),(0,G.jsxs)("form",{className:a.actions,onSubmit:d,children:[(0,G.jsxs)("div",{children:[(0,G.jsx)("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:(0,G.jsx)(ts,{})}),(0,G.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:(0,G.jsx)(Va,{})})]}),(0,G.jsxs)("div",{className:a.primaryButtons,children:[(0,G.jsx)(A.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),(0,G.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},fs=vm;var Pt=require("@reduxjs/toolkit");var _m=["{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}"],xm=new RegExp(_m.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Il(t,e){let o=t.split(xm),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 d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>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 Rl(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Al={suggestions:[],fetchState:"idle",isInitialRequest:null},Ll={default:Al},Ml=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Ol=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Nl=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")},eo=t=>t.textSuggestions,Dl=t=>e=>e.text.startsWith(t),hs=(0,Pt.createAction)("textSuggestions/refresh"),He=(0,Pt.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=Ut(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Fo(n),t);if(t==="default"){let p=i?l.filter(Dl(a)):l;e.dispatch(lt(p.slice(0,r)))}return l}),zo=(0,Pt.createAsyncThunk)("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...Fo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Dl(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Il(p.text,t):p.text}))),l=Rl(l,r),e.dispatch(lt(l)),l}),Bl=(0,Pt.createSlice)({name:"textSuggestions",initialState:Ll,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(He.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Al;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(He.rejected,(e,o)=>{let n=o.meta.arg;e[n].fetchState="error"}).addCase(He.fulfilled,(e,o)=>{let n=o.meta.arg;e[n].fetchState="done",e[n].suggestions=o.payload}).addCase(zo.pending,e=>{e.default.fetchState="loading"}).addCase(zo.rejected,e=>{e.default.fetchState="error"}).addCase(zo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(R,()=>Ll)}}),{setTextSuggestions:Hl,setSuggestionState:Fl}=Bl.actions,Kl=Bl.reducer;var zl=require("@reduxjs/toolkit");var Ul={contentType:null,suggestion:null},jl=t=>t.activeSuggestion.suggestion,Vl=t=>t.activeSuggestion.contentType,ql=(0,zl.createSlice)({name:"activeSuggestion",initialState:Ul,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(R,()=>Ul)}}),{setActiveSuggestion:Fe,resetActiveSuggestion:Ur}=ql.actions,Wl=ql.reducer;var zr={};j(zr,{enUS:()=>bm,nlNL:()=>Cm});var bm={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"}]},Cm={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 Gl=require("@reduxjs/toolkit"),wm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var $l=({ui:t})=>t.overlayCollapsed;var Xl=(0,Gl.createSlice)({name:"ui",initialState:wm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:jo,setInputHasFocus:to,setOverlayCollapsed:oo,setOpenOverlayWhenTyping:Ql,setOverlayCollapsedUserOverwrite:Zl}=Xl.actions,Jl=Xl.reducer;var Vo=T(require("react")),ec=require("react/jsx-runtime"),Yl=Vo.default.createContext(null),qo=({broadcastEvents:t,children:e})=>{let o=Vo.default.useMemo(()=>t,[]);return(0,ec.jsx)(Yl.Provider,{value:o,children:e})},ye=()=>{let t=(0,Vo.useContext)(Yl);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var no=require("@reduxjs/toolkit");var Tm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Ke=t=>t.auth.isLoggedIn,tc=t=>t.auth.loginFetchState,oc=t=>t.auth.verifyFetchState,nc=t=>t.auth.showLoginOverlay,mt=(0,no.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),sc=(0,no.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Wo=(0,no.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),rc=(0,no.createSlice)({name:"auth",initialState:Tm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(mt.pending,e=>{e.loginFetchState="loading"}),t.addCase(mt.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(mt.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Wo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Wo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Wo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:so,setShowLoginOverlay:ic}=rc.actions,ac=rc.reducer;var jr="SetActiveSuggestion",ro="ShowLoginOverlay",Vr="UserLoggedIn",Em="UserLoggedOut",Ue="ApplySuggestion",qr="ApplyImageSuggestion",km="ShowCommandPalette",Pm=t=>({[jr]:e=>{t.dispatch(Fl(e.state)),t.dispatch(Fe({contentType:e.contentType,suggestion:e.suggestion}))},[km]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch($(e.page))},[ro]:e=>{t.dispatch(ic(e))},[Vr]:()=>{t.dispatch(mt())},[Em]:()=>{t.dispatch(mt())},[qr]:e=>{t.dispatch(Yn({suggestion:e.suggestion}))},[Ue]:e=>{t.dispatch(we({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),lc=Pm;var Wr=require("react/jsx-runtime"),Im=()=>{var h;let[t,e]=(0,cc.useState)(!1),o=(0,io.useSelector)(jl),n=(0,io.useSelector)(Vl),s=(0,io.useSelector)(eo),r=(0,io.useDispatch)(),i=ye(),a=E(zr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ur()),r(to(!0)),r(Z.actions.reset())},p=(m,_)=>{r(Ur()),r(to(!0)),i.send(Ue,{text:m,suggestion:_})};if(o===null||n===null)return null;let d=(h=s[n])==null?void 0:h.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(Fe({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(Fe({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,Wr.jsx)(jt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,Wr.jsx)(fs,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:u})})},pc=Im;var $r=require("react-redux");var ys=T(require("classnames")),Ee=require("react"),Ss=require("react-redux");var dc=T(require("classnames"));var uc={root:"_root_1ukx5_1"};var mc=require("react/jsx-runtime"),Rm=({className:t,value:e,...o})=>{let n=y("TextInput",uc);return(0,mc.jsx)("input",{className:(0,dc.default)(t,n.root),type:"text",value:e,...o})},Go=Rm;var Gr={};j(Gr,{enUS:()=>Lm,nlNL:()=>Am});var Lm={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"}]},Am={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 gc={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 Mm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Om=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(Gr),i=y("LoginTokenDialog",gc),a=(0,Ss.useSelector)(oc),l=(0,Ss.useDispatch)(),c=b("productName"),[p,d]=(0,Ee.useState)(t||""),[u,g]=(0,Ee.useState)(0),[h,m]=(0,Ee.useState)(""),_=(0,Ee.useCallback)(async x=>{x.preventDefault(),l(sc({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},f=(0,Ee.useCallback)(async x=>{x.preventDefault();let P=Mm(x.target.elements.token.value);if(!P){m(r("verifyCodeError",{login:v}));return}l(Wo({token:P}))},[o]),v=(0,Ee.useMemo)(()=>x=>(0,K.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:x},"back-button"),[]);return(0,Ee.useEffect)(()=>{a==="error"&&m(r("verifyCodeError",{login:v})),a==="done"&&n()},[a]),(0,K.jsx)(jt,{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})}),u===0&&(0,K.jsxs)("form",{onSubmit:_,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,K.jsx)(Go,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>d(x.target.value)}),(0,K.jsx)("div",{className:i.actions,children:(0,K.jsx)("button",{type:"submit",className:(0,ys.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,K.jsxs)("form",{onSubmit:f,children:[(0,K.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,K.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,K.jsx)(Go,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&(0,K.jsx)("div",{className:i.errorMessage,children:h}),(0,K.jsxs)("div",{className:i.actions,children:[(0,K.jsx)("button",{type:"button",className:(0,ys.default)(i.button),onClick:w,children:r("back")}),(0,K.jsx)("button",{type:"submit",className:(0,ys.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},fc=Om;var yc=require("react/jsx-runtime"),Nm=()=>{let t=(0,$r.useSelector)(nc),e=(0,$r.useSelector)(fl),o=b("adminUrl"),n=ye(),s=()=>n.send(ro,!1),r=()=>{n.send(ro,!1),n.send(Vr)};return(0,yc.jsx)(fc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},hc=Nm;var Uc=T(require("lodash.debounce")),te=require("react"),Ve=require("react-redux");var vs=require("@reduxjs/toolkit");var Dm={data:null,fetchState:"idle"},Sc=t=>t.contentTypes.data,$o=(0,vs.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Bm=(0,vs.createSlice)({name:"contentTypes",initialState:Dm,reducers:{},extraReducers:t=>{t.addCase($o.pending,e=>{e.fetchState="loading"}).addCase($o.rejected,e=>{e.fetchState="error"}).addCase($o.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),vc=Bm.reducer;function Xo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}var _c=require("react");function xc(t,e){(0,_c.useEffect)(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}var Qo=require("react"),bs=require("react-redux");var _s=require("@reduxjs/toolkit");var bc={data:null,fetchState:"idle"},xs=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},ke=(0,_s.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)}),Hm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Fm=(0,_s.createSlice)({name:"entities",initialState:bc,reducers:{},extraReducers:t=>{t.addCase(ke.pending,e=>{e.fetchState="loading"}).addCase(ke.rejected,e=>{e.fetchState="error"}).addCase(ke.fulfilled,(e,o)=>{e.fetchState="done",e.data=Hm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(R,()=>bc)}}),Cc=Fm.reducer;var Xr={};j(Xr,{enUS:()=>Km,nlNL:()=>Um});var Km={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Um={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var wc={root:"_root_17kae_1",empty:"_empty_17kae_5"};var It=require("react/jsx-runtime"),zm=({onCopy:t,onUse:e})=>{let o=(0,Qo.useRef)(null),n=y("EntitiesList",wc),s=E(Xr),r=(0,bs.useSelector)(xs),i=(0,bs.useDispatch)();return(0,Qo.useEffect)(()=>{i(ke())},[]),(0,Qo.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,It.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,It.jsx)(A.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:(0,It.jsx)(A.List,{children:r.map((a,l)=>(0,It.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,It.jsx)("p",{className:n.empty,children:s("noResults")})]})},Tc=zm;var Pe=require("react"),Zo=require("react-redux");var Cs=require("@reduxjs/toolkit");var Ec={data:null,fetchState:"idle"},kc=t=>t.summary.data,Pc=t=>t.summary.fetchState==="error",ze=(0,Cs.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}}),jm=(0,Cs.createSlice)({name:"summary",initialState:Ec,reducers:{},extraReducers:t=>{t.addCase(ze.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(ze.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(ze.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(R,()=>Ec)}}),Ic=jm.reducer;var Qr={};j(Qr,{enUS:()=>Vm,nlNL:()=>qm});var Vm={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."}]},qm={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 Rc={root:"_root_18y7z_1",actions:"_actions_18y7z_5",main:"_main_18y7z_11",textInput:"_textInput_18y7z_15",loading:"_loading_18y7z_34",error:"_error_18y7z_38"};var je=require("react/jsx-runtime"),Wm=({onCopy:t})=>{let e=(0,Pe.useRef)(null),o=y("SummaryForm",Rc),[n,s]=(0,Pe.useState)(""),r=E(Qr),i=(0,Zo.useSelector)(kc),a=(0,Zo.useSelector)(Pc),l=(0,Zo.useDispatch)(),c=()=>{l(ie({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(ie({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return(0,Pe.useEffect)(()=>{l(ze())},[]),(0,Pe.useEffect)(()=>{s(i||"")},[i]),(0,Pe.useEffect)(()=>{e.current&&i&&e.current.focus()},[e,i]),(0,Pe.useEffect)(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),(0,je.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,je.jsx)("p",{className:o.error,children:r("error")}):(0,je.jsxs)(Pe.Fragment,{children:[(0,je.jsx)("div",{className:o.main,children:(0,je.jsx)("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),(0,je.jsx)("div",{className:o.actions,children:(0,je.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Lc=Wm;var Zr={};j(Zr,{enUS:()=>Gm,nlNL:()=>$m});var Gm={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},$m={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Rt=T(require("react")),Yo=require("react-redux");var Jr={};j(Jr,{enUS:()=>Xm,nlNL:()=>Qm});var Xm={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"}]},Qm={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 Ac={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 lo=require("@reduxjs/toolkit");var Yr={data:[],fetchState:"idle"},Mc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Oc=t=>t.answer.fetchState,co=(0,lo.createAction)("answer/resetKnowledgeSearch"),ao=(0,lo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeSearch({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),Zm=(0,lo.createSlice)({name:"answer",initialState:Yr,reducers:{},extraReducers:t=>{t.addCase(ao.pending,e=>{e.fetchState="loading"}).addCase(ao.rejected,e=>{e.fetchState="error"}).addCase(ao.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(R,()=>Yr).addCase(co,()=>Yr)}}),Nc=Zm.reducer;var Jo=require("react/jsx-runtime"),Dc=()=>(0,Jo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,Jo.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,Jo.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var ee=require("react/jsx-runtime"),Jm=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=Rt.default.useState(""),{setSelected:i}=pt(),a=(0,Rt.useRef)(null),l=y("EntitiesList",Ac),c=E(Jr),p=(0,Yo.useDispatch)(),d=(0,Yo.useSelector)(Mc),u=(0,Yo.useSelector)(Oc),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(ao({question:s,promptInstruction:n}))},h=(m,_)=>{p(ie({name:"knowledge assist source viewed",data:{question:_,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return(0,Rt.useEffect)(()=>{var m;o&&u==="idle"?p(ao({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,u]),(0,Rt.useEffect)(()=>{u==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(0),r(""))},[u,d]),(0,ee.jsxs)("div",{className:l.root,children:[d.length>0&&(0,ee.jsx)("div",{className:l.alignRight,children:(0,ee.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,ee.jsxs)(A.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:_},w)=>(0,ee.jsx)(A.List,{children:(0,ee.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:_.answer,closeOnSelect:!0,onClick:()=>t(_.answer),onSourceClick:f=>h(f,m),sources:_.sources,styles:{title:l.question,description:l.answer},children:m})},`${_.answer}_${w}`)),u==="loading"&&(0,ee.jsx)("p",{className:l.status,children:c("loading")}),u==="error"&&(0,ee.jsx)("p",{className:l.status,children:c("error")}),(0,ee.jsxs)("form",{className:l.form,onSubmit:g,children:[(0,ee.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),(0,ee.jsx)("button",{type:"submit",className:l.submit,children:(0,ee.jsx)(Dc,{})})]})]})]})},Bc=Jm;var ws=require("@reduxjs/toolkit");var Hc={data:null,fetchState:"idle"},po=t=>t.profile.data,Ts=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],en=(0,ws.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)}),Ym=(0,ws.createSlice)({name:"profile",initialState:Hc,reducers:{},extraReducers:t=>{t.addCase(en.pending,e=>{e.fetchState="loading"}).addCase(en.rejected,e=>{e.fetchState="error"}).addCase(en.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload}).addCase(R,()=>Hc)}}),Fc=Ym.reducer;var z=require("react/jsx-runtime"),eg=200,tg=5,og=4,ng=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Kc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),sg=()=>{let t=(0,Ve.useDispatch)(),e=ye(),o=E(Zr),[n,s]=(0,te.useState)(!1),[r,i]=(0,te.useState)(""),a=(0,Ve.useSelector)(_l),l=(0,Ve.useSelector)(po),[c,p]=(0,te.useState)(null),[d,u]=(0,te.useState)([]),[g,h]=(0,te.useState)(),m=(0,Ve.useSelector)(Ke),_=b("showSearch"),w=b("showEntitiesCommand"),f=b("showSummaryCommand"),v=b("showKnowledgeSearch"),x=b("showImageSearch"),P=b("searchTriggerKey"),C=(0,Ve.useSelector)(Sc),D=(0,Ve.useSelector)(xl),ne=(0,Ve.useSelector)(vl),F=S=>nr(D.filter(M=>M.type===S.toUpperCase()),S),L=[{value:"PERSONAL",label:o("personalSuggestions"),list:F("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:F("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:F("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:F("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(S=>S.shouldShow),se=[{label:o("entitiesClipboard"),onClick:()=>t($("entities")),shouldShow:w&&Kc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t($("summary")),shouldShow:f&&Kc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeSearch")}: ${r}`:o("knowledgeSearch"),onClick:()=>t($("knowledgeSearch")),shouldShow:v,experimental:!0}].filter(S=>S.shouldShow),_e=(C==null?void 0:C.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:F(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],tr=(0,te.useCallback)((0,Uc.default)((S,M)=>{t(Et({query:S,type:M,tags:["search-overlay"]}))},eg),[]),_t=ng([..._e,...L]),Yu=(0,te.useCallback)((S,M)=>{if(!M)return;let ot=[...L,..._e].find(({value:Dt})=>Dt===M);ot&&(t($("edit")),p(S),u(ot.list))},[t,c,_e]),or=(0,te.useCallback)((S,M)=>{switch(M.type){case"IMAGE":e.send(qr,{suggestion:M});break;default:e.send(Ue,{text:S,suggestion:M})}t(ae(!1))},[t]),ed=S=>{Xo(S.text),t(ie({name:"entity copied",data:{entity:S,type:"copy"}})),t(ae(!1))},td=S=>{e.send(Ue,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(ie({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t($("search")),t(co()),t(ae(!1))},od=S=>{Xo(S),t(ae(!1))},nd=S=>{e.send(Ue,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(ae(!1))},sd=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),rd=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function nr(S,M){return S.slice(0,g?10:M.toLowerCase()==="image"?og:tg)}function Hi(S,M,ot){return M.reduce((Dt,fn)=>ot&&g===ot?fn.length+Dt:nr(fn,ot).length+Dt,S)}function Nt(S){return M=>{n?window.confirm(o("warning"))&&(S(M),s(!1)):S(M)}}return(0,te.useEffect)(()=>{r?tr(r,g):t(us())},[r,g]),(0,te.useEffect)(()=>{a==="search"&&t(co())},[a]),(0,te.useEffect)(()=>{m&&t($o())},[m]),xc(P,()=>t(ae(!0))),!_||!l?null:(0,z.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Nt(S=>t(ae(S))),onChangeType:S=>h(S),onChangePage:Nt(S=>t($(S))),selectedType:g,search:r,page:a,isOpen:ne,types:[..._e,...L],children:[(0,z.jsx)(A.Page,{id:"search",children:(0,z.jsxs)(A.ActionsBar,{list:[...se.map(S=>({text:S.label,type:"command"})),..._t.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},M)=>or(S,_t[M]),onSecondary:(S,M)=>{Yu(_t[M-se.length],_t[M-se.length].type)},children:[se.length>0&&(0,z.jsx)(A.List,{heading:o("commands"),children:se.map((S,M)=>(0,z.jsx)(A.ListItem,{index:Hi(M,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[..._e,...L].map(({value:S,label:M,list:ot,lineClamp:Dt,listOrientation:fn},id)=>(0,z.jsx)(A.List,{heading:M,orientation:fn==="horizontal"?"horizontal":"vertical",children:nr(ot,S).map((xe,ad)=>(0,z.jsx)(A.ListItem,{index:Hi(se.length+ad,[..._e,...L].slice(0,id).map(({list:ld})=>ld),S),closeOnSelect:!1,lineClamp:Dt,onClick:()=>or(xe.text,xe),description:S!=="IMAGE"?xe.title&&xe.text:void 0,children:S==="IMAGE"?(0,z.jsx)(A.Image,{title:xe.title||xe.text,src:xe.image}):xe.title||xe.text},`${xe.id}-${xe.text}`))},S))]})}),(0,z.jsx)(A.Page,{id:"edit",onDismiss:Nt(()=>{t($("search")),p(null)}),children:c&&(0,z.jsx)(fs,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t($("search")),p(null),u([])},onNext:rd,onPrevious:sd,onUse:S=>{t($("search")),or(S,c),t(ae(!1)),u([]),p(null)}})}),(0,z.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Nt(()=>{t($("search"))}),children:(0,z.jsx)(Tc,{onUse:nd,onCopy:ed})}),(0,z.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Nt(()=>{t($("search"))}),children:(0,z.jsx)(Lc,{onCopy:od})}),(0,z.jsx)(A.Page,{id:"knowledgeSearch",title:o("knowledgeSearch"),isExperimental:!0,onDismiss:Nt(()=>{t(co()),t($("search"))}),children:(0,z.jsx)(Bc,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:td,onResetQuestion:()=>{t(co()),i("")}})})]})},zc=sg;var uo=require("react/jsx-runtime"),rg=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,uo.jsxs)(jc.Fragment,{children:[t&&(0,uo.jsx)(zc,{}),(0,uo.jsx)(pc,{}),e&&(0,uo.jsx)(hc,{})]})},Vc=rg;var qc=require("react-redux");var tn=require("react/jsx-runtime"),ig=({children:t})=>{let o=b("locale").replace("-","");return(0,tn.jsx)(dr.Provider,{value:o,children:t})},ag=({store:t,customStyles:e={},children:o})=>(0,tn.jsx)(qc.Provider,{store:t,children:(0,tn.jsx)(ig,{children:(0,tn.jsx)(xo.Provider,{value:e,children:o})})}),on=ag;var Is=T(require("classnames")),fo=require("react"),We=require("react-redux");var Wc=require("react");function Gc(t,e){let[o,n]=(0,Wc.useState)(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return k.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){k.error(i)}}]}function Es(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}var Xc=T(require("classnames")),qe=require("react");var ei={};j(ei,{enUS:()=>lg,nlNL:()=>cg});var lg={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"}]}]},cg={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Log in"}]},{type:0,value:" bij "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze voor "},{type:8,value:"min",children:[{type:0,value:"10 minuten"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 uur"}]},{type:0,value:" of "},{type:8,value:"day",children:[{type:0,value:"1 dag"}]}]};var $c={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var gt=require("react/jsx-runtime"),ti=(t,e,o)=>n=>(0,gt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),pg=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(ei),r=ye(),i=y("Login",$c),a=b("productName"),l=(0,qe.useCallback)(m=>{m.preventDefault(),n&&n(parseInt(m.target.value,10))},[]),c=(0,qe.useCallback)(m=>{m.preventDefault(),r.send(ro,!0)},[e]),p=(0,qe.useMemo)(()=>m=>(0,gt.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[e]),d=(0,qe.useCallback)(m=>(0,gt.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:u,hour:g,day:h}=(0,qe.useMemo)(()=>({min:ti(i,60*10,l),hour:ti(i,60*60,l),day:ti(i,60*60*12,l)}),[]);return(0,gt.jsxs)("div",{className:(0,Xc.default)(t,i.root),children:[s("loginPlease",{login:o?d:p,productName:a}),n&&(0,gt.jsxs)(qe.Fragment,{children:[(0,gt.jsx)("br",{}),s("snooze",{min:u,hour:g,day:h})]})]})},ks=pg;var Zc=require("react-redux");var Qc={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var nn=require("react/jsx-runtime"),ug=({title:t})=>{let e=y("SearchTrigger",Qc),o=(0,Zc.useDispatch)();return(0,nn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,nn.jsx)(Jt,{}),(0,nn.jsx)("span",{className:e.text,children:t})]})},Jc=ug;var ip=require("react");var sp=require("interweave"),go=require("react"),Ps=require("react-redux");var Yc=require("react");function ep(t,e,o){(0,Yc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var dg=/[.*+?^${}()|[\]\\]/g,mg=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function gg(t){return t.replace(dg,"\\$&")}function fg(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function oi(t){return t.search(mg)}function tp(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${gg(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function op(t){return t.replace(Kt,'<mark data-type="placeholder">$1</mark>')}function mo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function hg(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 ni(t,e,o={}){if(e){let n=fg(e.toLowerCase(),t.toLowerCase()),s=mo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=oi(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ya).length>3||e.length>30?hg(e.trim(),n):0;return`${`${i>0?"\u2026":""}${mo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var np={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};var si=require("react/jsx-runtime"),Sg=["search","personal-collection-search","studio-search"];function vg(t,e,o,n={}){let s="";return Sg.includes(e)?s=tp(ni(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=ni(t,o,n),n.placeholders===!0&&(s=op(s)),s}var _g=()=>{},xg=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Ps.useSelector)(Ut),r=(0,Ps.useDispatch)(),i=y("TextSuggestion",np),a=(0,go.useRef)(null);(0,go.useEffect)(()=>{let c=setTimeout(()=>{r(Na({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),ep(a,"click",()=>{r(es(t)),r(we({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,go.useMemo)(()=>vg(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,si.jsx)(N,{ref:a,as:"button",selected:e,onClick:_g,children:(0,si.jsx)(sp.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},rp=xg;var ri=require("react/jsx-runtime"),bg=({suggestions:t,selectedIndex:e})=>(0,ri.jsx)(ip.Fragment,{children:t.slice().map((o,n)=>(0,ri.jsx)(rp,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),ap=bg;var ii={};j(ii,{enUS:()=>Cg,nlNL:()=>wg});var Cg={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"}]},wg={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var lp={root:"_root_4kcme_1",isInline:"_isInline_4kcme_14",toggleButton:"_toggleButton_4kcme_18",toggleButtonWrapper:"_toggleButtonWrapper_4kcme_22",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_4kcme_29",isCollapsed:"_isCollapsed_4kcme_33",collapsible:"_collapsible_4kcme_33",hints:"_hints_4kcme_41",hintsHidden:"_hintsHidden_4kcme_48",triggers:"_triggers_4kcme_53",triggersRight:"_triggersRight_4kcme_68"};var B=require("react/jsx-runtime"),Tg=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",lp),s=E(ii),r=b("inlineSuggestions"),i=(0,We.useSelector)(Es),a=Ra(),l=(0,We.useDispatch)(),c=(0,fo.useRef)(null),p=b("searchTriggerKey"),d=b("productName"),u=(0,We.useSelector)($l),g=(0,We.useSelector)(Ke),h=(0,We.useSelector)(zn),[m,_]=(0,fo.useState)(null),w=b("showSearch"),f=b("showTextSuggestions"),v=b("adminUrl"),x=b("isEmbedded"),[P,C]=Gc("dd-snooze-until-ms",0),D=u||P>Date.now(),ne=e.filter(se=>se.source!=="gpt").length,F=()=>{D&&C(0),l(Zl(!D))},L=se=>{let _e=Date.now()+se*1e3;C(_e),k.info(`Snooze until: ${new Date(_e)}`),l(oo({collapse:!0}))};return(0,fo.useEffect)(()=>{ne===0&&_(null)},[e,ne]),Gt(()=>{l(oo({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||g===null||h===!1?null:g===!1?(0,B.jsxs)("div",{ref:c,className:(0,Is.default)(n.root,{[n.isCollapsed]:D,[n.isInline]:t}),"data-inline":t,children:[!D&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1}}),(0,B.jsx)("div",{className:n.triggersRight,children:(0,B.jsx)(wt,{className:n.toggleButton,title:s("collapse"),onClick:F,isCollapsed:!1})})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(wt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:F,isCollapsed:!0})}),(0,B.jsx)("div",{className:n.collapsible,children:(0,B.jsx)(ks,{loginUrl:v,isEmbedded:x,onSnooze:L})})]}):!a||!i?null:(0,B.jsxs)("div",{ref:c,className:(0,Is.default)(n.root,{[n.isCollapsed]:D,[n.isInline]:t}),"data-inline":t,children:[!D&&(0,B.jsxs)("div",{className:n.triggers,children:[(0,B.jsx)("div",{style:{flex:1},children:w&&(0,B.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>_(s(ls()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>_(null),children:(0,B.jsx)(Jc,{title:s("search")})})}),(0,B.jsxs)("div",{className:n.triggersRight,onFocus:()=>{},children:[(0,B.jsx)("div",{className:(0,Is.default)(!m&&n.hintsHidden,n.hints),children:m}),(0,B.jsx)(wt,{className:n.toggleButton,title:s("collapse"),onClick:F,isCollapsed:!1})]})]}),(0,B.jsx)("div",{className:n.toggleButtonWrapper,children:(0,B.jsx)(wt,{className:n.toggleButton,title:s("open",{productName:d}),onClick:F,isCollapsed:!0})}),ne>0&&f&&(0,B.jsx)("div",{className:n.collapsible,onFocus:()=>{},children:(0,B.jsx)(Ie,{children:(0,B.jsx)(ap,{suggestions:e,selectedIndex:o})})})]})},Eg=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Rs=(0,We.connect)(Eg)(Tg);var js=T(require("classnames")),Pp=require("interweave"),Qe=require("react"),Ip=require("react-redux");var cp=require("react"),kg=["div","span","mark","strong","b","i","u","em"];function ai(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(kg.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,cp.cloneElement)(n,{children:ai(i,e,o+1)})]}return[...t,...e]}function Ge(t){return t.tagName.toLowerCase()==="textarea"}var pp={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};var hp=require("interweave"),Os=require("react");var ci=T(require("classnames")),Se=require("react");var Ls=require("react"),Pg=["bottom","height","left","right","top","width"],Ig=(t={},e={})=>Pg.some(o=>t[o]!==e[o]),$e=new Map,up,dp=()=>{let t=[],e=[];$e.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Ig(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{$e.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),up=window.requestAnimationFrame(dp)};function Rg(t,e){return{observe(){let o=$e.size===0;if($e.has(t)){let n=$e.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else $e.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&dp()},unobserve(){let o=$e.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||$e.delete(t),$e.size||cancelAnimationFrame(up)}}}}function li(t){let[e,o]=(0,Ls.useState)(null);return(0,Ls.useLayoutEffect)(()=>{if(!t.current)return;let n=Rg(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var ho=require("react"),gp=require("react-dom");var mp={root:"_root_1jq08_1"};var fp=({children:t})=>{let[e,o]=(0,ho.useState)(null),n=(0,ho.useContext)(xo);return(0,ho.useLayoutEffect)(()=>{let s=document.createElement("div");return Tt(s),s.classList.add(mp.root),n!=null&&n.rootNode&&s.classList.add(n==null?void 0:n.rootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?(0,gp.createPortal)(t,e):null};var Me={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 As=require("react/jsx-runtime"),yo=(t=!1)=>{let[e,o]=(0,Se.useState)(t),n=(0,Se.useCallback)(()=>o(!0),[]),s=(0,Se.useCallback)(()=>o(!1),[]),r=(0,Se.useCallback)(()=>o(a=>!a),[]),i=(0,Se.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function pi(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 So=({className:t,triggerRef:e,boundaryRef:o=(0,Se.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=pi,...a})=>{let l=li(e),c=li(o),p=(0,Se.useMemo)(()=>i(l,c,0),[l,c]);return(0,As.jsx)(fp,{children:(0,As.jsx)("div",{className:(0,ci.default)(Me.ref,{[Me.positionAbove]:n==="above",[Me.positionBelow]:n==="below",[Me.positionLeft]:n==="left",[Me.positionRight]:n==="right",[Me.alignStart]:s==="start",[Me.alignCenter]:s==="center",[Me.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,As.jsx)("div",{className:(0,ci.default)(t,Me.root),children:r})})})};var ft=require("react/jsx-runtime"),Lg=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",ge),n=yo(document.activeElement===e);return Gt(()=>n.close()),(0,Os.useEffect)(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),(0,ft.jsxs)(Os.Fragment,{children:[(0,ft.jsx)("mark",{className:ge.caret,ref:n.triggerRef}),n.opened&&(0,ft.jsx)(So,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:(0,ft.jsx)("div",{style:t,className:o.suggestionsOverlayInputStyles,children:(0,ft.jsx)(Rs,{inline:!0})})})]})},Ms=class extends hp.Matcher{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(e,o){var n;return this.props=o,this.charCounter=0,this.onlyAtEnd=o.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(Ge(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:oi(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,ft.jsx)(Lg,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};var _p=T(require("classnames")),xp=require("interweave"),Fs=require("react");function yp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Ns(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function Sp(t){return t!=null}var vp=T(require("classnames")),Ds=require("react");var ui=require("react/jsx-runtime"),Bs=(0,Ds.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,Ds.useRef)(null),r=y("TabCompletion",ge);return(0,ui.jsx)("div",{ref:Ns([s,n]),className:(0,vp.default)(t,r.popoverContentContainer),...o,children:(0,ui.jsx)("div",{className:r.popoverContent,children:e})})});var ht=require("react/jsx-runtime"),Ag=t=>e=>{let o=pi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Mg=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",ge),i=yo(),a=(0,Fs.useMemo)(()=>Ag(t.getBoundingClientRect()),[t]),[l,c]=os(t);return(0,Fs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,ht.jsxs)("span",{children:[(0,ht.jsx)("mark",{ref:Ns([l,i.triggerRef]),className:(0,_p.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,ht.jsx)(So,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,ht.jsx)(Bs,{style:o,children:(0,ht.jsx)("div",{className:r.hintText,children:s})})})]})},Hs=class extends xp.Matcher{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${yp(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(Sp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,ht.jsx)(Mg,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Us=T(require("classnames")),Ep=require("interweave"),Q=require("react"),kp=require("react-redux");var di=require("react/jsx-runtime"),bp=()=>(0,di.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,di.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 yt=require("react"),sn=require("react-redux"),wp=T(require("lodash.debounce"));var Cp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Ks(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 mi(t){return t.replace("https://www.","").replace("https://","")}var ve=require("react/jsx-runtime"),Og=3,Ng=t=>({image:t.image||"",text:`https://${t.text}`,id:t.id,title:t.title}),Dg=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Og})=>{let r=y("LinkSearch",Cp),[i,a]=(0,yt.useState)(""),l=(0,sn.useDispatch)(),c=(0,sn.useSelector)(Ml("url")),p=(0,sn.useSelector)(bl("URL",Ng)),[d,u]=(0,yt.useState)(p.length-1),g=b("fallbackImage"),h=f=>{let v=f.target;a(v.value)},m=(f,v)=>{f.stopPropagation(),f.preventDefault(),window.open(v,"_blank")},_=f=>{var P;let v=d-1<0?p.length-1:d-1,x=d+1===p.length?0:d+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&u(v),f.code==="ArrowDown"&&u(x),f.code==="Enter"&&t(((P=p[d])==null?void 0:P.text)||i)},w=(0,yt.useCallback)((0,wp.default)(f=>{l(Et({query:f,type:"URL",tags:["link-search"]}))},300),[]);return(0,yt.useEffect)(()=>{i&&w(i)},[i]),(0,yt.useEffect)(()=>()=>{l(us())},[]),(0,ve.jsxs)("div",{className:r.root,children:[(0,ve.jsx)(Ie,{withDivider:!0,children:(i?p:c).slice(0,s).map((f,v)=>(0,ve.jsx)(N,{selected:d===v,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:(0,ve.jsxs)(H,{children:[(0,ve.jsx)(H.Image,{src:Ks(f,"small",g||void 0),title:f.title||f.text}),(0,ve.jsxs)(H.Content,{className:r.content,cropText:!0,children:[(0,ve.jsx)(H.Title,{children:f.title||mi(f.text)}),f.title&&mi(f.text)]}),(0,ve.jsx)(N.Actions,{children:(0,ve.jsx)(N.ActionButton,{label:n,onClick:x=>m(x,f.text)})})]})},f.text))}),(0,ve.jsx)(Go,{value:i,onChange:h,autoFocus:!0,placeholder:o,onKeyUp:_})]})},Tp=Dg;var gi={};j(gi,{enUS:()=>Bg,nlNL:()=>Hg});var Bg={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Hg={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var X=require("react/jsx-runtime"),Fg=(0,Q.forwardRef)((t,e)=>{let o=y("TabCompletion",ge);return(0,X.jsx)("mark",{ref:e,className:(0,Us.default)(o.matchSelection)},"selection-start")}),Kg=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(gi),i=y("TabCompletion",ge),a=(0,Q.useRef)(null),l=(0,Q.useRef)(null),[c,p]=(0,Q.useState)(null),d=(0,kp.useDispatch)(),u=yo(document.activeElement===n),[g]=(0,Q.useState)(()=>document.createRange());u.triggerRef.current=g,(0,Q.useEffect)(()=>()=>g.detach(),[]),(0,Q.useEffect)(()=>{let m=t.current,_=a.current;!m||!_||(g.setStart(m,0),g.setEnd(_,0))},[t.current,a.current]),Gt(()=>{u.close()});let h=(0,Q.useCallback)(m=>{let _=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(Xn({text:`[${_}](${w})`}))},[]);return(0,X.jsxs)("span",{children:[(0,X.jsx)("mark",{ref:a,className:(0,Us.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,X.jsx)(So,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,X.jsxs)(Bs,{style:o,ref:l,children:[(0,X.jsx)("div",{className:(0,Us.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,X.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,X.jsx)(bp,{}),(0,X.jsx)("span",{children:"\xA0"}),(0,X.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,X.jsx)(Tp,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},zs=class extends Ep.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,Q.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,X.jsx)(Fg,{ref:this.startRef}):(0,X.jsx)(Kg,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Xe=require("react/jsx-runtime"),Ug=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",pp),p=b("insertLink"),d=b("showMidSentenceSuggestions"),u=b("inlineSuggestions"),g=ss(a),h=(0,Qe.useRef)(null);(0,Qe.useEffect)(()=>{Ge(a)&&g&&rs(a,g)},[g]);let m=(0,Qe.useCallback)(f=>{if(!s||!o)return f;let v=[(0,Xe.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Xe.jsx)("span",{className:(0,js.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&v.push((0,Xe.jsx)("span",{className:(0,js.default)(c.hint,c.resetIndent),children:(0,Xe.jsx)(Dn,{keyCode:"tab"},"tabHint")})),ai(f,v)},[s,o,n]),_=(0,Qe.useMemo)(()=>{let f=[];return u&&f.push(new Ms("inline")),p&&f.push(new zs("selection")),f.push(new qt("placeholders")),r&&f.push(new Hs("keywords")),f},[u,p,r]),w=(0,Qe.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,Xe.jsxs)("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:w,children:[(0,Xe.jsx)(Pp.Interweave,{tagName:"span",containerTagName:"div",className:(0,js.default)(c.container,c.agentText),disableLineBreaks:Ge(a),content:e||"\u200B",onAfterParse:m,matchers:_,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!d}),(0,Xe.jsx)("br",{})]}):null},zg=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??mo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:h}=o;return{showTabHint:p,showStyleSuggestions:h,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},Rp=(0,Ip.connect)(zg)(Ug);var xu=T(require("classnames")),bu=require("react"),V=require("react-redux");var St=require("@reduxjs/toolkit");var Lp={list:[],fetchState:"idle",isInitialRequest:null},Mp=t=>t.autoflows.list||[],Ap=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},Ze=(0,St.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),fi=(0,St.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(Ze(t.platformSessionId))}),hi=(0,St.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(Ze(t.platformSessionId))}),jg=(0,St.createSlice)({name:"autoflows",initialState:Lp,reducers:{},extraReducers:t=>{t.addCase(fi.pending,(e,o)=>{let n=Ap(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(hi.pending,(e,o)=>{let n=Ap(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(Ze.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(Ze.rejected,e=>{e.fetchState="error"}),t.addCase(Ze.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(R,()=>Lp)}}),Op=(0,St.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(Ze(t))}),s.on("sessionCompleted",()=>{o(Ze(t))})}),Np=(0,St.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Dp=jg.reducer;var vt=require("@reduxjs/toolkit");var Bp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Hp=t=>t.customMessages.list,Fp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Kp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Up=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),rn=(0,vt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Vs=(0,vt.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)}),qs=(0,vt.createAsyncThunk)("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),zp=(0,vt.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(rn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(rn.rejected,e=>{e.fetchState="error"}).addCase(rn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Vs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Vs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(qs.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(R,()=>Bp)}}),jp=(0,vt.createAsyncThunk)("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(zp.actions.onCustomMessage(r))})}),Vp=(0,vt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),qp=zp.reducer;var an=require("@reduxjs/toolkit"),Vg={jwt:null,accountUrl:null,interval:null},Wp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},yi=(0,an.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),Si=(0,an.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(yi()),setInterval(()=>n(yi()),o)}),Gp=(0,an.createSlice)({name:"exchangeToken",initialState:Vg,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(yi.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(Si.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:$p}=Gp.actions,Xp=Gp.reducer;function Qp(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var ru=require("react"),iu=require("react-redux");var ou=T(require("classnames")),nu=require("react");var Jp=T(require("classnames"));var Zp={root:"_root_838fd_1"};var eu=require("react/jsx-runtime"),qg=({className:t,children:e})=>{let o=y("Unicode",Zp);return(0,eu.jsx)("span",{className:(0,Jp.default)(t,o.root),children:e})},Yp=qg;var tu={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var vi={};j(vi,{enUS:()=>Wg,nlNL:()=>Gg});var Wg={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"}]},Gg={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"),Xg=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",tu),a=E(vi),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(N,{className:(0,ou.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,le.jsx)(H,{children:(0,le.jsxs)(H.Content,{children:[(0,le.jsxs)(H.Title,{children:[e&&(0,le.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,le.jsx)("span",{children:n})]})}),(0,le.jsx)(N.Actions,{fixed:e==="Started",children:(0,le.jsx)(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,le.jsxs)(nu.Fragment,{children:[(0,le.jsx)(Yp,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},su=Xg;var _i=require("react/jsx-runtime"),Qg=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},Zg=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,_i.jsx)(ru.Fragment,{children:t.map(s=>(0,_i.jsx)(su,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Qg(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Jg=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Yg={onStartAutoflow:fi,onStopAutoflow:hi},au=(0,iu.connect)(Jg,Yg)(Zg);var Ws=require("react"),cu=require("react-redux"),Ci=T(require("classnames"));var xi=require("react/jsx-runtime"),bi=()=>(0,xi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,xi.jsx)("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var lu={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};var Oe=require("react/jsx-runtime"),ef=({entities:t})=>{let e=y("EntitiesWidgetList",lu),[o,n]=(0,Ws.useState)(void 0),s=(0,cu.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Xo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Ws.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Oe.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Oe.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Oe.jsx)("span",{className:e.entityText,children:a.text}),(0,Oe.jsxs)("span",{className:e.iconWrapper,children:[(0,Oe.jsx)("span",{className:(0,Ci.default)(e.icon),children:(0,Oe.jsx)(bi,{})}),(0,Oe.jsx)("span",{className:(0,Ci.default)(e.icon,o===l&&e.iconClicked),children:(0,Oe.jsx)(bi,{})})]})]},a.text))})},pu=ef;var uu=T(require("classnames")),wi=require("react"),Lt=require("react-redux");var ln={};j(ln,{enUS:()=>tf,nlNL:()=>of});var tf={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"}]},of={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 Je={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 oe=require("react/jsx-runtime"),nf=({suggestion:t})=>{let e=E(ln),o=(0,Lt.useDispatch)(),n=(0,Lt.useSelector)(Fp(t.text)),s=(0,Lt.useSelector)(Kp(t.text)),r=(0,Lt.useSelector)(Up(t.text)),i=(0,Lt.useSelector)(Kn),{replyOptions:a}=t,l=(0,wi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Vs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,wi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(qs({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,oe.jsxs)(N,{onClick:l,className:(0,uu.default)(Je.root,{[Je.isUsed]:n,[Je.hasError]:r}),children:[(0,oe.jsx)(H,{children:(0,oe.jsxs)(H.Content,{children:[(0,oe.jsxs)(H.Title,{className:Je.title,children:[t.text," ",(0,oe.jsx)(Bn,{className:Je.label,children:"analyse tool"})," ",r&&(0,oe.jsx)("span",{className:Je.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,oe.jsx)("ul",{className:Je.quickReplies,children:a.map(p=>(0,oe.jsx)("li",{className:Je.quickReply,children:p.title},p.title))})]})}),(0,oe.jsxs)(N.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,oe.jsx)(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,oe.jsx)(N.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,oe.jsx)(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},du=nf;var Ti=require("react/jsx-runtime"),mu=()=>(0,Ti.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Ti.jsx)("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});var hu=require("react-redux");var gu=require("react");var ce=require("react/jsx-runtime"),sf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=ds(s),i=E(ln),a=b("showImages"),l=b("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=(0,gu.useCallback)(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return(0,ce.jsxs)(N,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ce.jsxs)(H,{children:[a&&t.image&&(0,ce.jsx)(H.Image,{src:Ks(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(H.Content,{children:[t.title&&(0,ce.jsx)(H.Title,{children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,ce.jsx)(N.Labels,{labels:t.searchKeywords}),(0,ce.jsx)(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ce.jsxs)(N.Actions,{children:[r&&(0,ce.jsx)(N.ActionButton,{onClick:d,label:i("visitUrl")}),(0,ce.jsx)(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ce.jsx)(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},fu=sf;var cn=require("react/jsx-runtime"),rf=({contentType:t,lines:e,suggestions:o})=>{let n=ye(),s=(0,hu.useSelector)(eo),r=a=>{n.send(jr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ue,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,cn.jsx)(cn.Fragment,{children:o.map(a=>(0,cn.jsx)(fu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},yu=rf;var Ei={};j(Ei,{enUS:()=>af,nlNL:()=>lf});var af={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"}]},lf={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Vat gesprek samen"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var Su={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};var ki=require("react/jsx-runtime"),vu=()=>(0,ki.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,ki.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 Pi=require("react/jsx-runtime"),_u=()=>(0,Pi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Pi.jsx)("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});var I=require("react/jsx-runtime"),Gs=(t,e)=>{let o=(0,V.useSelector)(Ke);(0,bu.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},cf=()=>{let t=E(Ei),e=(0,V.useDispatch)(),o=b("isEmbedded"),n=y("Widget",Su),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,V.useSelector)(po),d=(0,V.useSelector)(Ts),u=(0,V.useSelector)(Mp),g=(0,V.useSelector)(xs),h=(0,V.useSelector)(Hp),m=(0,V.useSelector)(Un),_=(0,V.useSelector)(zn),w=(0,V.useSelector)(Ke),f=(0,V.useSelector)(Kn),v=(0,V.useSelector)(Qp),x=(0,V.useSelector)(eo),P=ye(),C=(0,V.useSelector)(Nl),D=(0,V.useSelector)(Wp("/admin/personal-collection")),ne=b("adminUrl");if(Gs(()=>(e(rn(f)),e(jp(f)),()=>{e(Vp(f))}),[e,_,r,f]),Gs(()=>(e(Ze(f)),e(Op(f)),()=>{e(Np(f))}),[e,_,s,f]),Gs(()=>{d.forEach(({type:L})=>{e(L==="entities"?ke():He(L))})},[e,_,m,p]),Gs(()=>(e(Si()),()=>{e($p())}),[e,_,i,m]),_===!1)return(0,I.jsx)("div",{className:n.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:t("notSupported")})})},"supported");if(w===!1)return(0,I.jsx)("div",{className:n.loginText,children:(0,I.jsx)("div",{children:(0,I.jsx)(ks,{isEmbedded:o,loginUrl:ne})})},"login");if(!p||!f||w===null||C||v)return(0,I.jsx)("div",{className:n.stateText,children:(0,I.jsx)("div",{children:(0,I.jsx)("p",{children:t("waiting")})})},"waiting");let F=c||a||l||D;return(0,I.jsx)("div",{className:(0,xu.default)(n.root),"data-testid":"widget",children:(0,I.jsxs)(Hn,{className:n.sectionList,children:[F&&(0,I.jsx)(nt,{title:t("actions"),type:"shortcuts",children:(0,I.jsxs)("div",{className:n.shortcutList,children:[c&&(0,I.jsxs)("button",{className:n.shortcut,onClick:()=>P.send("ShowCommandPalette",{isOpen:!0}),children:[(0,I.jsx)(Jt,{}),t("linkSearch")]}),a&&(0,I.jsxs)("button",{className:n.shortcut,onClick:()=>P.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,I.jsx)(_u,{}),t("linkSummary")]}),l&&(0,I.jsxs)("button",{className:n.shortcut,onClick:()=>P.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[(0,I.jsx)(vu,{}),t("linkKnowledgeSearch")]}),D&&(0,I.jsxs)("a",{className:n.shortcut,target:"_blank",href:D,rel:"noreferrer",children:[(0,I.jsx)(mu,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&(0,I.jsx)(nt,{type:"custom-messages","data-testid":"custom-messages",children:(0,I.jsx)(Ie,{withDivider:!0,children:h.map(L=>(0,I.jsx)(du,{suggestion:L},L.text))})}),s&&u.length>0&&(0,I.jsx)(nt,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,I.jsx)(Ie,{withDivider:!0,children:(0,I.jsx)(au,{})})}),d.map(({type:L,title:se,amount:_e,lines:tr})=>{var _t;switch(L){case"entities":return g&&g.length>0&&(0,I.jsx)(nt,{type:L,title:se,"data-testid":`type-${L}`,children:(0,I.jsx)(pu,{entities:g})},L);default:return((_t=x[L])==null?void 0:_t.fetchState)==="done"&&x[L].suggestions.length>0&&(0,I.jsx)(nt,{type:L,title:se,"data-testid":`type-${L}`,children:(0,I.jsx)(Ie,{withDivider:!0,children:(0,I.jsx)(yu,{lines:tr,contentType:L,suggestions:x[L].suggestions.slice(0,_e)||[]})})},L)}})]})})},Cu=cf;function wu(t){let e=new Range;return e.selectNodeContents(t),e}var pn=/[\u200B-\u200D\uFEFF]/g;function At(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,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let p=l.textContent,d=p.replace(pn,""),u=s+d.length,g=e>=s&&e<=u,h=o>=s&&o<=u;if(g){let m=i(p,e-s);m===0&&!h?n.setStartBefore(l):n.setStart(l,m)}h&&(n.setEnd(l,i(p,o-s)),r=!0),s=u;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 d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);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 $s(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 d=p===o,u=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;d&&(i=l+g.substring(0,n).replace(pn,"").length),u&&(a=l+g.substring(0,r).replace(pn,"").length),l+=g.replace(pn,"").length;break}case Node.ELEMENT_NODE:{let{tagName:g}=p,h=p.nextSibling===null;g==="BR"&&!h&&l++;for(let m=0;m<p.childNodes.length&&(d&&m===n&&(i=l),c(p.childNodes[m]),u&&m===r-1&&(a=l),a===void 0);m++);!u&&g==="DIV"&&!h&&l++,u&&(a=l);break}default:break}}if(c(t),a===void 0)throw new Error("Could not determine start and end");return{start:i??a,end:a}}function un(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,h=c.textContent.replace(pn,"");u===0&&g===void 0?a+=h:a+=h.substring(u,g);break}case Node.ELEMENT_NODE:{let{tagName:u}=c,g=c.nextSibling===null;i===0&&u==="BR"&&!g&&(a+=`
4
+ `);for(let h=p?n:0;h<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[h]),i!==1);h++);!d&&i===0&&u==="DIV"&&!g&&(a+=`
5
+ `);break}default:break}d&&i++}return l(t),a}var Mt=class extends Ne{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),un(this.element,e)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let e=window.getSelection();if(!e||e.rangeCount===0)return null;let o=e.getRangeAt(0);return!o||!this.element.contains(o.commonAncestorContainer)?null:$s(this.element,o)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:o}=this.currentSelection;return un(this.element,At(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 Ii=class{constructor(e){this.name=e;k.warn("BroadcastChannel is not supported")}postMessage(){}addEventListener(){}removeEventListener(){}close(){}},Ri=class{constructor(e,o){this.name=e;this.options=o;this.broadcastChannel=new this.options.broadcastChannelConstructor(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()}},Li=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()}},Ai=class{sessionId;deepdeskUrl;channel;defaultChannel;broadcastChannelConstructor;eventMap;isIntegration;constructor(e){this.deepdeskUrl=e.deepdeskUrl,this.broadcastChannelConstructor=e.broadcastChannelConstructor||window.BroadcastChannel||Ii,this.isIntegration=e.deepdeskUrl!==(e.origin||window.location.origin),this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}setSessionId(e){this.sessionId!==e&&(this.cleanup(),k.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.isIntegration?new Li(e,this.deepdeskUrl,{debug:!0}):new Ri(e,{broadcastChannelConstructor:this.broadcastChannelConstructor}),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&(k.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;k.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)}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Tu=Ai;var vo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Mi=t=>new Promise(e=>{setTimeout(e,t)});var _o=class extends vo{name="ClientError"},Oi=class extends vo{name="ServerError"},Ye=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}async request(e,o={}){let n={isStale:!1},s=`${this.baseUrl}${e}`,r=this.fetch,{abortLatest:i=!1,attempts:a=1,retryDelay:l=500,refreshTokenOn401:c=!0,retryOnError:p=x=>x instanceof TypeError,retryOnResponse:d=x=>x.status>=500,version:u="v1",...g}=o,h={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof u=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":u});let m=a,_=!1;if(!r)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&i&&(this.latestRequestByUrl[s].isStale=!0),this.latestRequestByUrl[s]=n;let w=async()=>(m--,r(s,h).then(async x=>d(x)&&!n.isStale&&m>0?(await Mi(l),w()):x.status===401&&c===!0&&_===!1?(_=!0,await this.refreshToken(),w()):x).catch(async x=>{if(p(x)&&!n.isStale&&m>0)return await Mi(l),w();throw x})),f=await w(),v=await f.json().catch(()=>null);if(n.isStale)throw new Error("Aborted");if(f.status>=500)throw new Oi("Server Error",v);if(f.status===401)throw new _o("Unauthorized",v);if(f.status===403)throw new _o("Forbidden",v);if(f.status===404)throw new _o("Not Found",v);if(f.status>=400)throw new _o("Bad Request",v);return delete this.latestRequestByUrl[s],v}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 pf;(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||={})})(pf||={});function Xs(t){return{...O(t),tags:t.tags}}var et=class t{constructor(e,o={}){this.options=o;this.client=new Ye(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(),k.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...U(e),tags:e.tags},{version:"v2"});return Xs(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(),k.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 Xs(r)}async isConversationSupported(e,o={}){k.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=U(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Xs(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...U(s),tags:s.tags})),{version:"v2"})).map(s=>Xs(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",U({...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:U({...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 k.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",U(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}`,U(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`,U(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",U(e),{abortLatest:!0});return O(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return O(o)}async knowledgeSearch(e,o,n){let s=await this.client.post("/api/knowledge-search/search",U({question:e.question,promptInstruction:e.promptInstruction,profile:n,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return O(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return O(o)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return O(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(Sa);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&k.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var dn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Dr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,O(s))}catch{k.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 uf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(uf||={});var mn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ye(e,o)}client;streams={};logger=k;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`,U(o));return O(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,U(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",U(e));return O(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new dn(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};var Js=require("@reduxjs/toolkit");var ku=require("@reduxjs/toolkit");var Eu={startTime:null,stopTime:null},Pu=(0,ku.createSlice)({name:"handlingTime",initialState:Eu,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(R,()=>Eu)}}),{handlingTimeStart:Iu,handlingTimeStop:Qs,handlingTimeReset:Ru}=Pu.actions,Lu=Pu.reducer;var Au=(t={})=>{let e={onAuthError:so(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var Zs=require("@reduxjs/toolkit");var Ni={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Ot=(0,Zs.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 Ni.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),df=(0,Zs.createSlice)({name:"styleSuggestions",initialState:Ni,reducers:{},extraReducers:t=>{t.addCase(Ot.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Ot.rejected,e=>{e.fetchState="error"}).addCase(Ot.fulfilled,(e,o)=>{e.fetchState="done",it(e.list,o.payload)||(e.list=o.payload)}).addCase(R,()=>Ni)}}),Mu=df.reducer;var Ou=(t={})=>{let e,o=!0,n={getStyleSuggestions:Ot,debounce:500,...t};return s=>r=>i=>{var g;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(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function mf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var Nu=(t={})=>{let e={getTextSuggestions:He,getAutocompleteSuggestions:zo,debounce:200,check:Es,...t},o;return n=>s=>r=>{var m;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,d=(m=l.conversation.current)==null?void 0:m.id,u=r.type===hs.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return mf(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let _=Ut(l);_===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(_))},u?0:e.debounce)),a}};var Du=Ot.fulfilled.toString();function gf(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 p;if(n.type!==Du){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(p=r.conversation)==null?void 0:p.current,{agentInfo:l}=r.info;if(s===i)return;let c=gf(s,i);n.type===Du&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:c}})};var ff=(0,Js.combineReducers)({activeSuggestion:Wl,answer:Nc,auth:ac,autoflows:Dp,conversation:Ea,contentTypes:vc,customMessages:qp,exchangeToken:Xp,entities:Cc,handlingTime:Lu,info:Sl,input:xr.reducer,overlayInput:Z.reducer,settings:ba,profile:Fc,search:wl,summary:Ic,styleSuggestions:Mu,ui:Jl,textSuggestions:Kl});function Hu(t){return(0,Js.configureStore)({reducer:ff,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Au(),Nu({debounce:200}),Ou({debounce:500}),Bu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var hf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},yf=t=>e=>o=>n=>{var a;let s=e.getState(),r=yr("inlineSuggestions")(s);switch(n.type){case Fe.toString():{let l=Ol(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 so.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:hf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Xn.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 Ro.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Yn.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case ke.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case ze.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 Qn.toString():t.handleKeyDown(n.payload);break;case Io.toString():t.logSendMessage(n.payload);break;case Zn.toString():t.logSendEditSuggestionMessage(n.payload);break;case Jn.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Io.toString():t.handleAfterSendMessage(n.payload);break;case jo.toString():t.onUpdateShowTabHint(n.payload);break;case Qs.toString():t.logHandlingTime();break;case we.toString():{r&&(e.dispatch(lt([])),e.dispatch(ct()));break}default:break}return i},Fu=yf;function Di(t){return t.toISOString().replace("T"," ").replace("Z","")}function Ku(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Di(o),timeStop:Di(n)}}function Bi(t,e,o){var P,C,D;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,pastes:p,cuts:d,deletions:u,textSuggestions:g,offeredTextSuggestions:h}}=e[t],m=n.length,w=g.reduce((ne,{text:F,searchTerm:L})=>ne+F.length-(L?L.length:0),0),f=c??Date.now(),v=(Date.now()-f)/1e3,x=s/v;return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:p,cuts:d,deletions:u,lenTextTyped:s,lenTextTotal:m,lenTextAssisted:w,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:v,charsPerSecond:x,numPastes:l,textSuggestionsV2:g,suggestionsCounters:[{source:"gpt",countOffered:h.filter(ne=>ne.source==="gpt").length}],agentId:(P=e.info.agentInfo)==null?void 0:P.agentId,agentName:(C=e.info.agentInfo)==null?void 0:C.agentName,agentEmail:(D=e.info.agentInfo)==null?void 0:D.agentEmail}}function Uu(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Uu(n,e):null}function zu(t,e){return Uu(t,e)}function ju(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Ys(t){return t instanceof HTMLElement&&(Ge(t)||ns(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{k.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function Sf(t){return t.offsetParent!==null}function qu(t){if(!Sf(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 er(t,e,o=100){let n=qu(t);e({isVisible:n});let s=setInterval(()=>{let r=qu(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var pe=require("react/jsx-runtime"),Wu=Vu("showTabHint",!0),gn=class t{static version="10.1.3";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}){let l=e.replace(/\/api$/,"");this.deepdeskApi=new et(l,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Fu({emit:(p,d,u)=>this.emit(p,d,u),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),logSendEditSuggestionMessage:p=>this.logSendEditMessage(p),onUpdateShowTabHint:p=>Wu.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};o&&Object.assign(c,{deepdeskBrokerAPI:new mn(o)}),this.store=Hu(c),this.broadcastEvents=new Tu({debug:!0,deepdeskUrl:l,eventMap:lc(this.store)}),this.store.dispatch(Po),this.store.dispatch(jo(Wu.value())),this.store.dispatch(Po({locale:s,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(k.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(k.warn("Profile has not been loaded (yet)"),!0):(k.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(so(null)),this.store.dispatch(mt()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Ke(n)&&tc(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){k.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(vr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(jn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Vn({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(_r(e))).payload}async postMessages(e){return(await this.store.dispatch(Wn(e))).payload}async updateConversation(e){return(await this.store.dispatch(qn(e))).payload}resetConversation(){this.store.dispatch(R()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(ze());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Po(e))}setVisitorInfo(e){this.store.dispatch(yl(e))}async setAgentInfo(e){await this.store.dispatch(Ho(e))}async setAgentSettings(e){await this.store.dispatch(Br(e))}async getAgentSettings(){return(await this.store.dispatch(Hr())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(hs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Jn(e))}syncInputHtml(e){this.store.dispatch(Ua(e))}notifyKeyDown(e){this.store.dispatch(Qn(e))}notifyPaste(e,o){this.store.dispatch(Fa({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(Ba(e))}notifyExternalSuggestion(e){this.store.dispatch(we(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Hl(e.contentType,e.suggestions)),this.store.dispatch(Fe({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(oo({collapse:!1})),this.inputMediator&&this.store.dispatch(La({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(lt([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Ha($n(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Oa()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(Da());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Ro()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(es(-1)),this.store.dispatch(Ro()),e.preventDefault()):o||(this.store.dispatch(oo({collapse:!0})),this.store.dispatch(Ql(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,p=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:d}=this.state.input;this.store.dispatch(jo(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&d&&d.text.startsWith(p)&&(this.store.dispatch(we({text:d.text,suggestion:d,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(ct())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ka()),this.store.dispatch(lt([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(Iu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(Qs()))}logSendMessage(e){let o=Bi("input",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Bi("overlayInput",this.state,{version:"v2"});e&&Object.assign(o,{text:e}),this.store.dispatch(Ma(this.state.overlayInput.metrics)),this.deepdeskApi.sendEvent("suggestion edited",{data:o})}logHandlingTime(){let e=Ku(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Ru())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(Io(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){k.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),k.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]=Xt(n,s);return r.dataset.testid=e,o!=null&&o.rootNode&&r.classList.add(o.rootNode),this.unmountHandlers.push(()=>{(0,tt.unmountComponentAtNode)(r),i(),r.remove()}),r}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Tt(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,tt.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(!Ys(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:d,detectSubmit:u,insertLink:g,inputMediator:h,closestScrollSelector:m,appendOverlayTo:_,inlineSuggestions:w}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w});let f=m&&zu(e,m)||void 0,v=this.overlayContainerFactory("deepdesk-tab-completion",n,e,{appendTo:_,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",n,f||e,{appendTo:_});o.automaticHandlingTime&&this.setupHandlingTime(e),(0,tt.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Rp,{inputElement:e})})}),v),(0,tt.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Rs,{})})}),x),(0,tt.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Vc,{})})}),this.createContainer("deepdesk-overlays")),Tt(e),this.inputMediator=h||(Ge(e)?new De(e):new Mt(e)),this.inputMediator.on("change",({plainText:C})=>{this.notifyInputChanged(C)}),this.inputMediator.on("updated",({rawHtml:C})=>{C!=null&&this.syncInputHtml(C)}),this.inputMediator.on("keydown",C=>{this.notifyKeyDown(C)}),this.inputMediator.on("paste",({pastedText:C,selectionText:D})=>{this.notifyPaste(C,D)}),this.inputMediator.on("cut",({selectionText:C})=>{this.notifyCut(C)});let P;this.inputMediator.on("selection",C=>{clearTimeout(P),C===null?P=setTimeout(()=>{C!==null&&this.store.dispatch(br(C))},500):this.store.dispatch(br(C))}),this.inputMediator.on("disabled",()=>{var C;(C=this.inputMediator)==null||C.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(to(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(to(!0))),this.store.dispatch(Aa({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var C;this.refresh(),this.broadcastEvents.setSessionId((C=this.state.conversation.current)==null?void 0:C.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&k.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,tt.render)((0,pe.jsx)(on,{store:this.store,customStyles:n,children:(0,pe.jsx)(qo,{broadcastEvents:this.broadcastEvents,children:(0,pe.jsx)(Cu,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,tt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=er(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ju(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(en());let e=po(this.state);e&&this.store.dispatch(Po({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeSearch,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(k.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;k.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=Ts(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ke()):this.store.dispatch(He(n))})}catch(n){this.handleError(n)}}};async function Gu(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function $u(t,e,o={}){let n=o.replace?At(t,o.replace.start,o.replace.end):wu(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),e.split(`
6
+ `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}),n.commonAncestorContainer===t&&n.surroundContents(document.createElement("div"))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?At(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Xu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Qu(t,e,o){await new et(t).authenticateWithKey(e,o)}async function Zu(t){let o=await new Ye(t).get("/platform/config/",{version:null});return O(o)}async function vf(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function Ju(t,e){let o=await vf(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,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});