@deepdesk/deepdesk-sdk 10.4.0 → 10.4.1-beta.0

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,7 +1,7 @@
1
- "use strict";var yu=Object.create;var _n=Object.defineProperty;var Su=Object.getOwnPropertyDescriptor;var vu=Object.getOwnPropertyNames;var _u=Object.getPrototypeOf,xu=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var o in e)_n(t,o,{get:e[o],enumerable:!0})},Wi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vu(e))!xu.call(t,s)&&s!==o&&_n(t,s,{get:()=>e[s],enumerable:!(n=Su(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?yu(_u(t)):{},Wi(e||!t||!t.__esModule?_n(o,"default",{value:t,enumerable:!0}):o,t)),bu=t=>Wi(_n({},"__esModule",{value:!0}),t);var Mf={};j(Mf,{Card:()=>D,Chip:()=>ia,ContentEditableInput:()=>Bt,DeepdeskAPI:()=>nt,DeepdeskSDK:()=>Sn,HTTPClient:()=>Ie,InputMediator:()=>Ke,InputType:()=>it,KeyboardHint:()=>Un,Label:()=>zn,Locale:()=>Mo,Section:()=>rt,SectionList:()=>jn,Sources:()=>be,Suggestion:()=>O,SuggestionList:()=>ge,TextAreaInput:()=>Ue,ToggleButton:()=>Rt,attachFile:()=>iu,authenticateWithKey:()=>su,createFullRange:()=>wo,createOverlayContainer:()=>At,createRangeFromOffsets:()=>Ct,escapeHTML:()=>vo,fetchPlatformConfig:()=>ru,formatTextMarkup:()=>nu,getRangeOffsets:()=>mn,getRangeText:()=>fn,insertCKEditor:()=>ou,isSupportedInputElement:()=>ar,updateContentEditable:()=>tu,updateTextArea:()=>eu,useStyles:()=>S,waitForElementVisibilityChange:()=>lr});module.exports=bu(Mf);var Cn=T(require("classnames")),pe=T(require("react"));var xn=T(require("react")),Gi=T(require("classnames")),ko=xn.default.createContext({});function S(t,e){let{debug:o,...n}=(0,xn.useContext)(ko),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Gi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var $i={root:"_root_vr71j_1"};var Tt=require("react/jsx-runtime"),bn=()=>(0,Tt.jsxs)("svg",{className:$i.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Tt.jsx)("defs",{children:(0,Tt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Tt.jsx)("title",{children:"Failed loading image"}),(0,Tt.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 ur={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 Et=require("react/jsx-runtime"),wn=(0,pe.createContext)(ur),Cu=({title:t,src:e})=>{let o=(0,pe.useContext)(wn),[n,s]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{s(!1)},[e]),(0,Et.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Et.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Et.jsx)(bn,{})})},wu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,pe.useContext)(wn);return(0,Et.jsx)("div",{className:(0,Cn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Tu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,pe.useContext)(wn);return pe.default.createElement(t,{className:(0,Cn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Tn=({children:t})=>{let e=S("Card",ur);return(0,Et.jsx)("div",{className:(0,Cn.default)(e.root),children:(0,Et.jsx)(wn.Provider,{value:e,children:t})})};Tn.Image=Cu;Tn.Content=wu;Tn.Title=Tu;var D=Tn;var Xi={root:"_root_nkim0_1"};var Fn=require("react");var gr=function(t,e){return gr=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])},gr(t,e)};function Ro(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");gr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var re=function(){return re=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},re.apply(this,arguments)};function Qi(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function En(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 kn;(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"})(kn||(kn={}));var Rn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var xe;(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"})(xe||(xe={}));var Pn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Pn||(Pn={}));function mr(t){return t.type===xe.literal}function Zi(t){return t.type===xe.argument}function In(t){return t.type===xe.number}function An(t){return t.type===xe.date}function Ln(t){return t.type===xe.time}function Mn(t){return t.type===xe.select}function On(t){return t.type===xe.plural}function Ji(t){return t.type===xe.pound}function Nn(t){return t.type===xe.tag}function Dn(t){return!!(t&&typeof t=="object"&&t.type===Pn.number)}function Po(t){return!!(t&&typeof t=="object"&&t.type===Pn.dateTime)}function fr(t){t.forEach(function(e){if(delete e.location,Mn(e)||On(e))for(var o in e.options)delete e.options[o].location,fr(e.options[o].value);else In(e)&&Dn(e.style)||(An(e)||Ln(e))&&Po(e.style)?delete e.style.location:Nn(e)&&fr(e.children)})}function Yi(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Rn(t,e).parse();if(o.err){var n=SyntaxError(kn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||fr(o.val),o.val}function Hn(t,e){var o=e&&e.cache?e.cache:Au,n=e&&e.serializer?e.serializer:Iu,s=e&&e.strategy?e.strategy:ku;return s(t,{cache:o,serializer:n})}function Eu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function ea(t,e,o,n){var s=Eu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function ta(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 hr(t,e,o,n,s){return o.bind(e,t,n,s)}function ku(t,e){var o=t.length===1?ea:ta;return hr(t,this,o,e.cache.create(),e.serializer)}function Ru(t,e){return hr(t,this,ta,e.cache.create(),e.serializer)}function Pu(t,e){return hr(t,this,ea,e.cache.create(),e.serializer)}var Iu=function(){return JSON.stringify(arguments)};function yr(){this.cache=Object.create(null)}yr.prototype.get=function(t){return this.cache[t]};yr.prototype.set=function(t,e){this.cache[t]=e};var Au={create:function(){return new yr}},Bn={variadic:Ru,monadic:Pu};var kt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(kt||(kt={}));var Io=function(t){Ro(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 Sr=function(t){Ro(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('", "'),'"'),kt.INVALID_VALUE,r)||this}return e}(Io);var oa=function(t){Ro(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),kt.INVALID_VALUE,s)||this}return e}(Io);var na=function(t){Ro(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,'"'),kt.MISSING_VALUE,n)||this}return e}(Io);var W;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(W||(W={}));function Lu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==W.literal||o.type!==W.literal?e.push(o):n.value+=o.value,e},[])}function Mu(t){return typeof t=="function"}function Ao(t,e,o,n,s,r,i){if(t.length===1&&mr(t[0]))return[{type:W.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(mr(p)){a.push({type:W.literal,value:p.value});continue}if(Ji(p)){typeof r=="number"&&a.push({type:W.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new na(d,i);var u=s[d];if(Zi(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?W.literal:W.object,value:u});continue}if(An(p)){var m=typeof p.style=="string"?n.date[p.style]:Po(p.style)?p.style.parsedOptions:void 0;a.push({type:W.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(Ln(p)){var m=typeof p.style=="string"?n.time[p.style]:Po(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:W.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(In(p)){var m=typeof p.style=="string"?n.number[p.style]:Dn(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(u=u*(m.scale||1)),a.push({type:W.literal,value:o.getNumberFormat(e,m).format(u)});continue}if(Nn(p)){var f=p.children,g=p.value,x=s[g];if(!Mu(x))throw new oa(g,"function",i);var w=Ao(f,e,o,n,s,r),h=x(w.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?W.literal:W.object,value:C}}))}if(Mn(p)){var y=p.options[u]||p.options.other;if(!y)throw new Sr(p.value,u,Object.keys(p.options),i);a.push.apply(a,Ao(y.value,e,o,n,s));continue}if(On(p)){var y=p.options["=".concat(u)];if(!y){if(!Intl.PluralRules)throw new Io(`Intl.PluralRules is not available in this environment.
1
+ "use strict";var yu=Object.create;var _n=Object.defineProperty;var Su=Object.getOwnPropertyDescriptor;var vu=Object.getOwnPropertyNames;var _u=Object.getPrototypeOf,xu=Object.prototype.hasOwnProperty;var j=(t,e)=>{for(var o in e)_n(t,o,{get:e[o],enumerable:!0})},Wi=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vu(e))!xu.call(t,s)&&s!==o&&_n(t,s,{get:()=>e[s],enumerable:!(n=Su(e,s))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?yu(_u(t)):{},Wi(e||!t||!t.__esModule?_n(o,"default",{value:t,enumerable:!0}):o,t)),bu=t=>Wi(_n({},"__esModule",{value:!0}),t);var Mf={};j(Mf,{Card:()=>D,Chip:()=>ia,ContentEditableInput:()=>Ft,DeepdeskAPI:()=>nt,DeepdeskSDK:()=>Sn,HTTPClient:()=>Ie,InputMediator:()=>Ke,InputType:()=>it,KeyboardHint:()=>Un,Label:()=>zn,Locale:()=>Oo,Section:()=>rt,SectionList:()=>jn,Sources:()=>be,Suggestion:()=>O,SuggestionList:()=>ge,TextAreaInput:()=>Ue,ToggleButton:()=>Rt,attachFile:()=>iu,authenticateWithKey:()=>su,createFullRange:()=>To,createOverlayContainer:()=>Lt,createRangeFromOffsets:()=>Ct,escapeHTML:()=>_o,fetchPlatformConfig:()=>ru,formatTextMarkup:()=>nu,getRangeOffsets:()=>mn,getRangeText:()=>fn,insertCKEditor:()=>ou,isSupportedInputElement:()=>ar,updateContentEditable:()=>tu,updateTextArea:()=>eu,useStyles:()=>S,waitForElementVisibilityChange:()=>lr});module.exports=bu(Mf);var Cn=T(require("classnames")),pe=T(require("react"));var xn=T(require("react")),Gi=T(require("classnames")),Ro=xn.default.createContext({});function S(t,e){let{debug:o,...n}=(0,xn.useContext)(Ro),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:(0,Gi.default)(a,l,o?`${t}__${i}`:!1)}},{}):e}var $i={root:"_root_vr71j_1"};var Tt=require("react/jsx-runtime"),bn=()=>(0,Tt.jsxs)("svg",{className:$i.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[(0,Tt.jsx)("defs",{children:(0,Tt.jsx)("style",{children:".cls-1 { fill: #b3b3b3; }"})}),(0,Tt.jsx)("title",{children:"Failed loading image"}),(0,Tt.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 ur={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 Et=require("react/jsx-runtime"),wn=(0,pe.createContext)(ur),Cu=({title:t,src:e})=>{let o=(0,pe.useContext)(wn),[n,s]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{s(!1)},[e]),(0,Et.jsx)("div",{className:o.imageWrapper,children:e&&!n?(0,Et.jsx)("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):(0,Et.jsx)(bn,{})})},wu=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=(0,pe.useContext)(wn);return(0,Et.jsx)("div",{className:(0,Cn.default)(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Tu=({as:t="h1",cropText:e=!1,className:o,children:n,...s})=>{let r=(0,pe.useContext)(wn);return pe.default.createElement(t,{className:(0,Cn.default)(r.title,o,{[r.contentIsCropped]:e}),...s},n)},Tn=({children:t})=>{let e=S("Card",ur);return(0,Et.jsx)("div",{className:(0,Cn.default)(e.root),children:(0,Et.jsx)(wn.Provider,{value:e,children:t})})};Tn.Image=Cu;Tn.Content=wu;Tn.Title=Tu;var D=Tn;var Xi={root:"_root_nkim0_1"};var Fn=require("react");var gr=function(t,e){return gr=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])},gr(t,e)};function Po(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");gr(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var re=function(){return re=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},re.apply(this,arguments)};function Qi(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function En(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 kn;(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"})(kn||(kn={}));var Rn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var xe;(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"})(xe||(xe={}));var Pn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Pn||(Pn={}));function mr(t){return t.type===xe.literal}function Zi(t){return t.type===xe.argument}function In(t){return t.type===xe.number}function An(t){return t.type===xe.date}function Ln(t){return t.type===xe.time}function Mn(t){return t.type===xe.select}function On(t){return t.type===xe.plural}function Ji(t){return t.type===xe.pound}function Nn(t){return t.type===xe.tag}function Dn(t){return!!(t&&typeof t=="object"&&t.type===Pn.number)}function Io(t){return!!(t&&typeof t=="object"&&t.type===Pn.dateTime)}function fr(t){t.forEach(function(e){if(delete e.location,Mn(e)||On(e))for(var o in e.options)delete e.options[o].location,fr(e.options[o].value);else In(e)&&Dn(e.style)||(An(e)||Ln(e))&&Io(e.style)?delete e.style.location:Nn(e)&&fr(e.children)})}function Yi(t,e){e===void 0&&(e={}),e=re({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new Rn(t,e).parse();if(o.err){var n=SyntaxError(kn[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||fr(o.val),o.val}function Hn(t,e){var o=e&&e.cache?e.cache:Au,n=e&&e.serializer?e.serializer:Iu,s=e&&e.strategy?e.strategy:ku;return s(t,{cache:o,serializer:n})}function Eu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function ea(t,e,o,n){var s=Eu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function ta(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 hr(t,e,o,n,s){return o.bind(e,t,n,s)}function ku(t,e){var o=t.length===1?ea:ta;return hr(t,this,o,e.cache.create(),e.serializer)}function Ru(t,e){return hr(t,this,ta,e.cache.create(),e.serializer)}function Pu(t,e){return hr(t,this,ea,e.cache.create(),e.serializer)}var Iu=function(){return JSON.stringify(arguments)};function yr(){this.cache=Object.create(null)}yr.prototype.get=function(t){return this.cache[t]};yr.prototype.set=function(t,e){this.cache[t]=e};var Au={create:function(){return new yr}},Bn={variadic:Ru,monadic:Pu};var kt;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(kt||(kt={}));var Ao=function(t){Po(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 Sr=function(t){Po(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('", "'),'"'),kt.INVALID_VALUE,r)||this}return e}(Ao);var oa=function(t){Po(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),kt.INVALID_VALUE,s)||this}return e}(Ao);var na=function(t){Po(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,'"'),kt.MISSING_VALUE,n)||this}return e}(Ao);var W;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(W||(W={}));function Lu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==W.literal||o.type!==W.literal?e.push(o):n.value+=o.value,e},[])}function Mu(t){return typeof t=="function"}function Lo(t,e,o,n,s,r,i){if(t.length===1&&mr(t[0]))return[{type:W.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(mr(p)){a.push({type:W.literal,value:p.value});continue}if(Ji(p)){typeof r=="number"&&a.push({type:W.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new na(d,i);var u=s[d];if(Zi(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?W.literal:W.object,value:u});continue}if(An(p)){var m=typeof p.style=="string"?n.date[p.style]:Io(p.style)?p.style.parsedOptions:void 0;a.push({type:W.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(Ln(p)){var m=typeof p.style=="string"?n.time[p.style]:Io(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:W.literal,value:o.getDateTimeFormat(e,m).format(u)});continue}if(In(p)){var m=typeof p.style=="string"?n.number[p.style]:Dn(p.style)?p.style.parsedOptions:void 0;m&&m.scale&&(u=u*(m.scale||1)),a.push({type:W.literal,value:o.getNumberFormat(e,m).format(u)});continue}if(Nn(p)){var f=p.children,g=p.value,x=s[g];if(!Mu(x))throw new oa(g,"function",i);var w=Lo(f,e,o,n,s,r),h=x(w.map(function(C){return C.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(C){return{type:typeof C=="string"?W.literal:W.object,value:C}}))}if(Mn(p)){var y=p.options[u]||p.options.other;if(!y)throw new Sr(p.value,u,Object.keys(p.options),i);a.push.apply(a,Lo(y.value,e,o,n,s));continue}if(On(p)){var y=p.options["=".concat(u)];if(!y){if(!Intl.PluralRules)throw new Ao(`Intl.PluralRules is not available in this environment.
2
2
  Try polyfilling it using "@formatjs/intl-pluralrules"
3
- `,kt.MISSING_INTL_API,i);var _=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));y=p.options[_]||p.options.other}if(!y)throw new Sr(p.value,u,Object.keys(p.options),i);a.push.apply(a,Ao(y.value,e,o,n,s,u-(p.offset||0)));continue}}return Lu(a)}function Ou(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 Nu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Ou(t[n],e[n]),o},re({},t)):t}function vr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Du(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Hn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,En([void 0],o,!1)))},{cache:vr(t.number),strategy:Bn.variadic}),getDateTimeFormat:Hn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,En([void 0],o,!1)))},{cache:vr(t.dateTime),strategy:Bn.variadic}),getPluralRules:Hn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,En([void 0],o,!1)))},{cache:vr(t.pluralRules),strategy:Bn.variadic})}}var sa=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,m){return!u.length||m.type!==W.literal||typeof u[u.length-1]!="string"?u.push(m.value):u[u.length-1]+=m.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Ao(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Qi(i,["formatters"]);this.ast=t.__parse(e,re(re({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Nu(t.formats,n),this.formatters=s&&s.formatters||Du(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=Yi,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 Hu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Bu="dummy",_r=(0,Fn.createContext)(null);function E(t){let e=(0,Fn.useContext)(_r);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=Hu(o,n);return r?new sa(r).format(s):(e!==Bu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var xr={};j(xr,{enUS:()=>Fu,nlNL:()=>Ku});var Fu={experimental:[{type:0,value:"Experimental"}]},Ku={experimental:[{type:0,value:"Experimenteel"}]};var br=require("react/jsx-runtime"),ra=({children:t})=>{let e=S("Chip",Xi);return(0,br.jsx)("span",{className:e.root,children:t})},Kn=()=>{let t=E(xr);return(0,br.jsx)(ra,{children:t("experimental")})},ia=ra;var la=T(require("classnames"));var aa={root:"_root_cq1yq_1"};var ca=require("react/jsx-runtime");var Uu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},zu=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",aa);return(0,ca.jsx)("span",{"data-key":Uu[e],className:(0,la.default)(t,n.root),...o})},Un=zu;var da=T(require("classnames"));var pa={root:"_root_4a08n_1"};var ua=require("react/jsx-runtime"),ju=({className:t,children:e,...o})=>{let n=S("Label",pa);return(0,ua.jsx)("span",{...o,className:(0,da.default)(t,n.root),children:e})},zn=ju;var ga={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var zt=require("react/jsx-runtime"),qu=({title:t,children:e,type:o,...n})=>{let s=S("Section",ga);return(0,zt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,zt.jsx)("div",{className:s.subTitleContainer,children:(0,zt.jsx)("span",{className:s.subtitle,children:t})}),(0,zt.jsx)("div",{className:s.suggestions,children:e})]})},rt=qu;var fa=T(require("classnames")),ha=T(require("react"));var ma={root:"_root_19wxp_1"};var ya=require("react/jsx-runtime"),Vu=ha.default.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",ma);return(0,ya.jsx)("div",{ref:o,className:(0,fa.default)(n.root,t),children:e})}),jn=Vu;var Lo=T(require("classnames")),ue=T(require("react"));var Cr={root:"_root_fsa1k_10",fadein:"_fadein_fsa1k_1",isClickable:"_isClickable_fsa1k_45",isSelected:"_isSelected_fsa1k_50",actions:"_actions_fsa1k_74",actionsIsFixed:"_actionsIsFixed_fsa1k_96",actionButton:"_actionButton_fsa1k_104",dropdownList:"_dropdownList_fsa1k_125",dropdownButton:"_dropdownButton_fsa1k_140",dropdownItem:"_dropdownItem_fsa1k_150",dropdownItemButton:"_dropdownItemButton_fsa1k_159",actionButtonIsPrimary:"_actionButtonIsPrimary_fsa1k_173",actionButtonIsDisabled:"_actionButtonIsDisabled_fsa1k_177",labels:"_labels_fsa1k_185",label:"_label_fsa1k_185"};var de=require("react/jsx-runtime"),jt=(0,ue.createContext)(Cr),Wu=({fixed:t,children:e,...o})=>{let n=(0,ue.useContext)(jt);return(0,de.jsx)("div",{...o,className:(0,Lo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Gu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ue.useContext)(jt);return(0,de.jsxs)("div",{className:(0,Lo.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})]})},$u=({index:t,label:e,onClick:o})=>{let n=(0,ue.useContext)(jt);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})})},Xu=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ue.useContext)(jt);return(0,de.jsx)("button",{type:"button",className:(0,Lo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},wr=({labels:t})=>{let e=(0,ue.useContext)(jt);return(0,de.jsx)("div",{className:e.labels,children:t.map(o=>(0,de.jsx)("span",{className:e.label,children:o},o))})},qt=ue.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",Cr),l=(0,ue.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,de.jsx)(s,{...r,ref:i,className:(0,Lo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,de.jsx)(jt.Provider,{value:a,children:n})})});qt.Labels=wr;qt.Actions=Wu;qt.ActionButton=Xu;qt.DropdownButton=Gu;qt.DropdownItem=$u;var O=qt;var va=T(require("classnames"));var Sa={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var _a=require("react/jsx-runtime"),Qu=({withDivider:t,children:e})=>{let o=S("SuggestionList",Sa);return(0,_a.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,va.default)(o.root,{[o.isWithDivider]:t}),children:e})},ge=Qu;var ba=T(require("classnames"));var xa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var qn=require("react/jsx-runtime"),Zu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",xa);return(0,qn.jsx)("button",{type:"button",className:(0,ba.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,qn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,qn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Rt=Zu;var Ca=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Vt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var wa=/x-deepdesk-(([a-z0-9\-_])+-version)/,be=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(be||{}),it=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(it||{});var Ae=require("react-dom");var Xc=require("react");var Ta=require("@reduxjs/toolkit"),Ea=require("react-redux");var Mo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Mo||{});var Ju={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"},ka=(0,Ta.createSlice)({name:"settings",initialState:Ju,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Oo}=ka.actions,Tr=t=>e=>e.settings[t],b=t=>(0,Ea.useSelector)(Tr(t)),Ra=ka.reducer;var hc=require("react"),uo=require("react-redux");var Me=require("@reduxjs/toolkit"),Ma=require("diff"),Oa=require("react-redux");function Pa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function at(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)=>at(r,e[i],o-1)):Pa(t)&&Pa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>at(t[i],e[i],o-1)):!1}function Yu(t){return Math.max(...t.map(e=>e.length))}function eg(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 Ia(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Yu(n);s++){let r=eg(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 tg=2;function Er(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ia(t,tg);return o&&o.text!==e?o:t[0]}var Ce=require("@reduxjs/toolkit"),Aa={current:null,isSupported:null},I=(0,Ce.createAction)("resetConversation"),Vn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Wn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Wt=t=>t.conversation.isSupported,kr=(0,Ce.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Gn=(0,Ce.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),$n=(0,Ce.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Xn=(0,Ce.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Wn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Rr=(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})})}),Qn=(0,Ce.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Wn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),og=[Gn.rejected,$n.rejected,Xn.rejected,Qn.rejected].map(t=>t==null?void 0:t.toString()),ng=(0,Ce.createSlice)({name:"conversation",initialState:Aa,reducers:{},extraReducers:t=>{t.addCase(kr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Gn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase($n.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Rr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Xn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Qn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(I,()=>Aa).addMatcher(e=>og.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),La=ng.reducer;var lt={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Jn(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 Yn=(0,Me.createAction)("input/replaceText"),es=(0,Me.createAction)("input/keyDown"),Pt=(0,Me.createAction)("input/sendMessage"),ts=(0,Me.createAction)("input/sendEditSuggestionMessage"),os=(0,Me.createAction)("input/uiInputChange"),ns=(0,Me.createAction)("input/applyImageSuggestion"),ie=(0,Me.createAction)("input/sendEvent");function Zn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Na=t=>(0,Me.createSlice)({name:t,initialState:lt,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,{...lt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Er(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(at(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Zn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:x}=o.payload,w=(0,Ma.diffChars)(g,x);g.length-x.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-x.length;break}case"C":case"V":case"X":if(!u&&!m){e.metrics.numCharsTyped+=1;let g=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!u&&!m&&!f){e.metrics.numCharsTyped+=1;let g=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=lt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Zn(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"&&Zn(e)},commitSuggestion(e){Zn(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=Er(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)}},extraReducers:e=>{e.addCase(I,o=>{o.tabCompletionSuggestion=lt.tabCompletionSuggestion,o.previousKeyDownEvent=lt.previousKeyDownEvent,o.textSuggestions=lt.textSuggestions,o.selectedSuggestionIndex=lt.selectedSuggestionIndex,o.metrics=lt.metrics})}}),Pr=Na("input"),Gt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),sg=t=>t.input.selection,Da=()=>(0,Oa.useSelector)(sg),{userInput:Ha,changeSelection:Ir,initialInput:Ba,mergeMetrics:Fa,nextTextSuggestionIndex:Ka,offeredTextSuggestion:Ua,previousTextSuggestionIndex:za,registerCut:ja,registerKeyDown:qa,registerPaste:Va,reset:Wa,resetToCommitted:No,platformInput:Ga,setSelectedTextSuggestionIndex:Do,setTextSuggestions:Be,stageSuggestion:we,commitSuggestion:ct}=Pr.actions,Y=Na("overlay");var $t=require("react");var $a={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Ar=require("react/jsx-runtime"),rg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,$t.useRef)(null),l=(0,$t.useRef)(null),c=S("Dialog",$a);return(0,$t.useEffect)(()=>{var u,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},d=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.removeEventListener("click",d),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),(0,$t.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,Ar.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Ar.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},Xt=rg;var Qr=require("react"),vs=require("react-redux");var Lr={};j(Lr,{enUS:()=>ig,nlNL:()=>ag});var ig={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?"}]},ag={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 Xa={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 Ho=require("react/jsx-runtime"),ss=()=>(0,Ho.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ho.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ho.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 Bo=require("react/jsx-runtime"),Qa=()=>(0,Bo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Bo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Bo.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 me=require("react"),gl=require("react-redux"),ml=require("interweave"),zr=T(require("classnames"));var Mr={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 Ja=require("interweave"),Ya=T(require("classnames"));var Qt=require("react");function Za(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function rs(t){let e=(0,Qt.useRef)(null),[o,n]=(0,Qt.useState)(!1);return(0,Qt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Za((p,d)=>{let u=e.current;if(!u)return;let m=p/r,f=d/r,g=u.getBoundingClientRect(),x=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;x&&!s?(s=!0,n(!0)):!x&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Za(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var Fe={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Or=require("react/jsx-runtime"),lg=({inputElement:t,children:e})=>{let o=S("TabCompletion",Fe),[n,s]=rs(t);return(0,Or.jsx)("mark",{ref:n,className:(0,Ya.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Zt=class extends Ja.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,Or.jsx)(lg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Jt=require("react");function is(t){return t.contentEditable==="true"}function cg(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 el(t){let{selectionStart:e,selectionEnd:o}=is(t)?cg(t):t;return[e,o]}function as(t){let[,e]=(0,Jt.useState)(),o=(0,Jt.useRef)(null);return o.current=el(t),(0,Jt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=el(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function ls(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Vt);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 tl=require("react");function Yt(t){(0,tl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function It(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var ol,Oe=new Map,pg=["bottom","height","left","right","top","width"],dg=(t={},e={})=>pg.some(o=>t[o]!==e[o]);function nl(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...nl(e)]:[]}function sl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Nr=!1,rl=()=>{Nr=!0;let t=[];Oe.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Oe.delete(o);return}let n=o.getBoundingClientRect();dg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(sl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Oe.size!==0&&(ol=window.requestAnimationFrame(rl))};function Dr(t,e){let o=nl(t),n=[],s=o.map((r,i)=>Dr(r,a=>{n[i]=a;let l=Oe.get(t);if(!l)return;let c=n.reduce(sl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Oe.has(t)){let i=Oe.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Oe.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Nr&&rl()},unobserve(){s.forEach(i=>i.unobserve());let r=Oe.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Oe.delete(t),Oe.size||(cancelAnimationFrame(ol),Nr=!1)}}}}var il,Ne=new Map,al=()=>{Ne.forEach((t,e)=>{if(!e.isConnected){Ne.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)))}),Ne.size!==0&&(il=window.requestAnimationFrame(al))};function ll(t,e){return{observe(){let o=Ne.size===0;Ne.has(t)?Ne.get(t).callbacks.push(e):Ne.set(t,{visible:void 0,callbacks:[e]}),o&&al()},unobserve(){let o=Ne.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ne.delete(t),Ne.size||cancelAnimationFrame(il)}}}}var Hr=["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 Br(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function eo(t){return parseFloat(t)}function cs(t){return Math.round(t*1e6)}function cl(t){return t/1e6}function Fr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=eo(t.width),r=eo(t.borderLeftWidth),i=eo(t.borderRightWidth),a=eo(t.paddingRight),l=cl(cs(s)-cs(r)-cs(i)),c=cl(cs(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function At(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",It(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Br(n,o,Hr),Fr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ll(t,()=>{Br(n,o,Hr),Fr(n,t,o),r(),setTimeout(r,0)}),a=Dr(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(Br(n,o,Hr),Fr(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=eo(d.borderTopWidth),m=eo(d.borderBottomWidth),f=p.top+u-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Kr={};j(Kr,{enUS:()=>ug,nlNL:()=>gg});var ug={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"}]},gg={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 Fo=require("react/jsx-runtime"),pl=()=>(0,Fo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Fo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Fo.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 Ur=require("react/jsx-runtime"),dl=()=>(0,Ur.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Ur.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"})});function mg(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ps(t){return t?t instanceof ShadowRoot?ps(t.host):t===t.ownerDocument.body?t.ownerDocument:mg(t)?t:ps(t.parentNode):document.body}var ul=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ul||{}),Ke=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();at(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ul).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",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)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()});let o=ps(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}this.currentSelection=this.getSelection()}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 Ue=class extends Ke{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var ee=require("react/jsx-runtime"),fg=({value:t,onUse:e,...o})=>{var p;let n=E(Kr),s=(0,gl.useDispatch)(),r=S("EditSuggestionTextInput",Mr),[i,a]=(0,me.useState)(null),l=(0,me.useRef)(null),c=((p=t.match(Vt))==null?void 0:p.length)||0;return(0,me.useEffect)(()=>{let d;return l.current&&(a(l.current),d=new Ue(l.current),d.on("change",({plainText:u})=>{s(Y.actions.userInput({text:u,selection:d.getSelection()}))}),d.on("keydown",u=>{s(Y.actions.registerKeyDown(Jn(u))),u.code==="Enter"&&u.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:u,selectionText:m})=>{s(Y.actions.registerPaste({text:u,selectionText:m}))}),d.on("cut",({selectionText:u})=>{s(Y.actions.registerCut(u))})),()=>{s(Y.actions.reset()),d.dispose(),d.deactivate()}},[l]),(0,me.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,me.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,ee.jsxs)("div",{className:r.textInputWrapper,children:[(0,ee.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,ee.jsx)(hg,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,zr.default)(r.alert,c===0?r.success:r.warning),children:[(0,ee.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,ee.jsx)(pl,{}):(0,ee.jsx)(dl,{})]})]})},hg=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",Mr),n=(0,me.useRef)(null),s=as(t);return(0,me.useEffect)(()=>{ls(t,s)},[s,t]),(0,ee.jsx)(yg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,zr.default)(o.root,o.agentText),children:[(0,ee.jsx)(ml.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new Zt("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},yg=({inputElement:t,children:e})=>{let o=(0,me.useRef)(null);return(0,me.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=At(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,ee.jsx)("div",{ref:o,children:e})},fl=fg;var so=require("react");var hl=require("react"),ds=T(require("classnames"));var te={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var Lt={};j(Lt,{enUS:()=>Sg,nlNL:()=>vg});var Sg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},vg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var pt=require("react/jsx-runtime"),_g=({src:t,title:e})=>{let o=S("CommandPalette",te),[n,s]=(0,hl.useState)("loading"),r=E(Lt);return(0,pt.jsxs)("div",{className:o.image,children:[(0,pt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ds.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,pt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,pt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:(0,pt.jsx)(bn,{})}),e&&(0,pt.jsx)("span",{className:o.imageTitle,children:e})]})},yl=_g;var Sl=T(require("react")),vl=T(require("classnames"));var Ko=require("react/jsx-runtime");function jr({children:t,heading:e,orientation:o}){let n=S("CommandPalette",te);return Sl.default.Children.count(t)===0?null:(0,Ko.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Ko.jsx)("h4",{className:n.listHeading,children:e}),(0,Ko.jsx)("div",{className:(0,vl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Uo=T(require("classnames"));var us=T(require("react")),bl=require("react/jsx-runtime"),_l=us.default.createContext(void 0);function dt(){let t=us.default.useContext(_l);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var xl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=us.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,bl.jsx)(_l.Provider,{value:i,children:t})};var fe=require("react/jsx-runtime");function qr({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}=dt(),m=S("CommandPalette",te);function f(g){n(g),t&&u(!1)}return(0,fe.jsxs)("div",{className:(0,Uo.default)(m.listItem,d===r&&m.listItemSelected),children:[(0,fe.jsxs)("button",{type:"button",className:(0,Uo.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:[(0,fe.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,fe.jsx)("p",{className:(0,Uo.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,fe.jsx)("p",{className:(0,Uo.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&(0,fe.jsx)(Kn,{})]}),l&&(0,fe.jsxs)("div",{className:m.sources,children:[(0,fe.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(g=>g.url?(0,fe.jsx)("a",{className:m.source,href:g.url,target:"_blank",title:g.url,rel:"noopener noreferrer",onClick:()=>s&&s(g),children:g.name},g.url):(0,fe.jsx)("span",{className:m.source,children:g.name},g.name))]})]})}var ut=require("react/jsx-runtime");function Vr({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=E(Lt),i=S("CommandPalette",te),{page:a}=dt();return a!==o?null:(0,ut.jsxs)("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,ut.jsxs)("div",{className:i.pageNav,children:[(0,ut.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:n,children:[(0,ut.jsx)(ss,{}),r("back")]}),e&&(0,ut.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,ut.jsx)(Kn,{})]}),t]})}var gt=require("react");var gs=()=>/Mac/i.test(navigator.platform);var fs=require("@reduxjs/toolkit");var xg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=xg;var to=require("@reduxjs/toolkit");function bg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function M(t){return Array.isArray(t)?t.map(M):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[bg(o)]:M(t[o])}),{}):t}function Wr(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,[Wr(o)]:U(t[o])}),{}):t}var Cg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},jo=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)||""}},zo=(0,to.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?M(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),M(n))}),Gr=(0,to.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}),$r=(0,to.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Cl=t=>t.info.agentInfo,wl=(0,to.createSlice)({name:"info",initialState:Cg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(zo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(zo.rejected,e=>{e.fetchState="error"}).addCase(zo.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(Gr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase($r.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(I,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Tl}=wl.actions,El=wl.reducer;var ms={list:[],fetchState:"idle",isOpen:!1,page:"search"},kl=t=>t.search.isOpen,Rl=t=>t.search.page,Pl=t=>t.search.list;function Il(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Mt=(0,fs.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:jo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Al=(0,fs.createSlice)({name:"search",initialState:ms,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ms.fetchState,t.list=ms.list}},extraReducers:t=>{t.addCase(Mt.pending,e=>{e.fetchState="loading"}).addCase(Mt.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Mt.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(I,()=>ms)}}),{resetSearch:hs,setIsOpen:ae,setPage:X}=Al.actions,Ll=Al.reducer;var wg=/(https?:\/\/[^\s]+)/,ys=t=>t.split(" ").find(e=>wg.test(e));var Xr=T(require("classnames"));var Ss=require("react/jsx-runtime"),Tg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",te);return(0,Ss.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Xr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,Ss.jsx)("span",{className:(0,Xr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},oo=Tg;var ze=require("react/jsx-runtime"),Eg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",te),a=E(Lt),{selected:l,setSelected:c}=dt(),p=r[l],d=p&&typeof p.text=="string"&&ys(p.text),u=(0,gt.useRef)(null);function m(y){if(!u.current)return;let _=u.current.querySelectorAll(".command-palette-list-item"),C=0,K=0;y==="down"?(_.forEach((Le,B)=>{B===l&&(C=B)}),K=C===_.length-1?0:C+1):y==="up"?(_.forEach((Le,B)=>{B===l&&(C=B)}),K=C?C-1:_.length-1):c(0);let H=_[K];H&&typeof K=="number"&&(c(K),H.scrollIntoView&&H.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function f(){if(!u.current)return;let y=u.current.querySelectorAll(".command-palette-list-item"),_=0;y.forEach((K,H)=>{H===l&&(_=H)});let C=y[_];C&&C.click()}let g=()=>{d&&window.open(d,"_blank")},x=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,gt.useCallback)(y=>{if(y.key==="Enter"&&y.altKey&&d){g();return}if(y.key==="Enter"&&y.shiftKey){w();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),m("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),m("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return(0,gt.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,ze.jsxs)("div",{className:i.actions,children:[(0,ze.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,ze.jsxs)("div",{className:i.actionsBar,children:[d&&(0,ze.jsx)(oo,{onClick:g,shortKeys:[gs()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,ze.jsxs)(gt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,ze.jsx)(oo,{onClick:w,shortKeys:[8679,8629],children:o}),(0,ze.jsx)(oo,{onClick:x,shortKeys:[8629],children:e})]})]})]})},Ol=Eg;var Nl=require("react");var qo=require("react/jsx-runtime"),no=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,qo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,qo.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 kg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",te);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(no,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&(0,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Dl=(0,Nl.forwardRef)(kg);var Vo=require("react/jsx-runtime");function Ot({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[m,f]=(0,so.useState)(0),g=(0,so.useRef)(null),x=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return(0,so.useEffect)(()=>{f(0)},[u,n]),(0,Vo.jsx)(Xt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:x,children:(0,Vo.jsxs)(xl,{selected:m,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Vo.jsx)(Dl,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Ot.Page=Vr;Ot.List=jr;Ot.Image=yl;Ot.ListItem=qr;Ot.ActionsBar=Ol;Ot.Button=oo;var A=Ot;var G=require("react/jsx-runtime"),Rg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",Xa),l=(0,vs.useDispatch)(),c=E(Lr),p=(0,vs.useSelector)(f=>f.overlayInput.text);(0,Qr.useEffect)(()=>{t&&(l(Y.actions.reset()),l(Y.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Y.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(ts(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return(0,Qr.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,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)(wr,{labels:t.searchKeywords}),(0,G.jsx)(fl,{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&&m(r),children:(0,G.jsx)(ss,{})}),(0,G.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,G.jsx)(Qa,{})})]}),(0,G.jsxs)("div",{className:a.primaryButtons,children:[(0,G.jsx)(A.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,G.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},_s=Rg;var Nt=require("@reduxjs/toolkit");var Pg=["{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}"],Ig=new RegExp(Pg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Hl(t,e){let o=t.split(Ig),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 Bl(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Kl={suggestions:[],fetchState:"idle",isInitialRequest:null},Fl={default:Kl},Ul=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},zl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},jl=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")},ro=t=>t.textSuggestions,ql=t=>{let e=t.toLowerCase();return o=>o.text.toLowerCase().startsWith(e)},xs=(0,Nt.createAction)("textSuggestions/refresh"),je=(0,Nt.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=Gt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,jo(n),t);if(t==="default"){let p=i?l.filter(ql(a)):l;e.dispatch(Be(p.slice(0,r)))}return l}),Wo=(0,Nt.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,{...jo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(ql(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Hl(p.text,t):p.text}))),l=Bl(l,r),e.dispatch(Be(l)),l}),Vl=(0,Nt.createSlice)({name:"textSuggestions",initialState:Fl,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(je.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Kl;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(je.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(je.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Wo.pending,e=>{e.default.fetchState="loading"}).addCase(Wo.rejected,e=>{e.default.fetchState="error"}).addCase(Wo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(I,()=>Fl)}}),{setTextSuggestions:Wl,setSuggestionState:Gl}=Vl.actions,$l=Vl.reducer;var Ql=require("@reduxjs/toolkit");var Xl={contentType:null,suggestion:null},Zl=t=>t.activeSuggestion.suggestion,Jl=t=>t.activeSuggestion.contentType,Yl=(0,Ql.createSlice)({name:"activeSuggestion",initialState:Xl,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(I,()=>Xl)}}),{setActiveSuggestion:qe,resetActiveSuggestion:Zr}=Yl.actions,ec=Yl.reducer;var Jr={};j(Jr,{enUS:()=>Ag,nlNL:()=>Lg});var Ag={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"}]},Lg={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 tc=require("@reduxjs/toolkit"),Mg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var bs=({ui:t})=>t.overlayCollapsed;var oc=(0,tc.createSlice)({name:"ui",initialState:Mg,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:Go,setInputHasFocus:io,setOverlayCollapsed:mt,setOpenOverlayWhenTyping:nc,setOverlayCollapsedUserOverwrite:sc}=oc.actions,rc=oc.reducer;var $o=T(require("react")),ac=require("react/jsx-runtime"),ic=$o.default.createContext(null),ao=({broadcastEvents:t,children:e})=>{let o=$o.default.useMemo(()=>t,[]);return(0,ac.jsx)(ic.Provider,{value:o,children:e})},he=()=>{let t=(0,$o.useContext)(ic);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var lo=require("@reduxjs/toolkit");var Og={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Ee=t=>t.auth.isLoggedIn,lc=t=>t.auth.loginFetchState,cc=t=>t.auth.verifyFetchState,pc=t=>t.auth.showLoginOverlay,ft=(0,lo.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),dc=(0,lo.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Xo=(0,lo.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),uc=(0,lo.createSlice)({name:"auth",initialState:Og,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(ft.pending,e=>{e.loginFetchState="loading"}),t.addCase(ft.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(ft.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Xo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Xo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Xo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:co,setShowLoginOverlay:gc}=uc.actions,mc=uc.reducer;var Yr="SetActiveSuggestion",po="ShowLoginOverlay",ei="UserLoggedIn",Ng="UserLoggedOut",Ve="ApplySuggestion",ti="ApplyImageSuggestion",Dg="ShowCommandPalette",Hg=t=>({[Yr]:e=>{t.dispatch(Gl(e.state)),t.dispatch(qe({contentType:e.contentType,suggestion:e.suggestion}))},[Dg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[po]:e=>{t.dispatch(gc(e))},[ei]:()=>{t.dispatch(ft())},[Ng]:()=>{t.dispatch(ft())},[ti]:e=>{t.dispatch(ns({suggestion:e.suggestion}))},[Ve]:e=>{t.dispatch(we({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),fc=Hg;var oi=require("react/jsx-runtime"),Bg=()=>{var f;let[t,e]=(0,hc.useState)(!1),o=(0,uo.useSelector)(Zl),n=(0,uo.useSelector)(Jl),s=(0,uo.useSelector)(ro),r=(0,uo.useDispatch)(),i=he(),a=E(Jr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Zr()),r(io(!0)),r(Y.actions.reset())},p=(g,x)=>{r(Zr()),r(io(!0)),i.send(Ve,{text:g,suggestion:{...x,source:`${x.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(qe({contentType:n,suggestion:s[n].suggestions[d-1]})),m=d===s[n].suggestions.length-1||d===null?void 0:()=>r(qe({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,oi.jsx)(Xt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,oi.jsx)(_s,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:u})})},yc=Bg;var si=require("react-redux");var Cs=T(require("classnames")),ke=require("react"),ws=require("react-redux");var vc=T(require("classnames"));var Sc={root:"_root_1ukx5_1"};var _c=require("react/jsx-runtime"),Fg=({className:t,value:e,...o})=>{let n=S("TextInput",Sc);return(0,_c.jsx)("input",{className:(0,vc.default)(t,n.root),type:"text",value:e,...o})},Qo=Fg;var ni={};j(ni,{enUS:()=>Kg,nlNL:()=>Ug});var Kg={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"}]},Ug={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 xc={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 F=require("react/jsx-runtime");var zg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},jg=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(ni),i=S("LoginTokenDialog",xc),a=(0,ws.useSelector)(cc),l=(0,ws.useDispatch)(),c=b("productName"),[p,d]=(0,ke.useState)(t||""),[u,m]=(0,ke.useState)(0),[f,g]=(0,ke.useState)(""),x=(0,ke.useCallback)(async _=>{_.preventDefault(),l(dc({email:p})),m(1)},[o,p]),w=()=>{g(""),m(0)},h=(0,ke.useCallback)(async _=>{_.preventDefault();let C=zg(_.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:y}));return}l(Xo({token:C}))},[o]),y=(0,ke.useMemo)(()=>_=>(0,F.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:_},"back-button"),[]);return(0,ke.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),(0,F.jsx)(Xt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,F.jsxs)("div",{className:i.root,children:[(0,F.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&(0,F.jsxs)("form",{onSubmit:x,children:[(0,F.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,F.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,F.jsx)(Qo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:_=>d(_.target.value)}),(0,F.jsx)("div",{className:i.actions,children:(0,F.jsx)("button",{type:"submit",className:(0,Cs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,F.jsxs)("form",{onSubmit:h,children:[(0,F.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,F.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,F.jsx)(Qo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,F.jsx)("div",{className:i.errorMessage,children:f}),(0,F.jsxs)("div",{className:i.actions,children:[(0,F.jsx)("button",{type:"button",className:(0,Cs.default)(i.button),onClick:w,children:r("back")}),(0,F.jsx)("button",{type:"submit",className:(0,Cs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},bc=jg;var wc=require("react/jsx-runtime"),qg=()=>{let t=(0,si.useSelector)(pc),e=(0,si.useSelector)(Cl),o=b("adminUrl"),n=he(),s=()=>n.send(po,!1),r=()=>{n.send(po,!1),n.send(ei)};return(0,wc.jsx)(bc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Cc=qg;var Gc=T(require("lodash.debounce")),ne=require("react"),$e=require("react-redux");var Ts=require("@reduxjs/toolkit");var Vg={data:null,fetchState:"idle"},Tc=t=>t.contentTypes.data,Zo=(0,Ts.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Wg=(0,Ts.createSlice)({name:"contentTypes",initialState:Vg,reducers:{},extraReducers:t=>{t.addCase(Zo.pending,e=>{e.fetchState="loading"}).addCase(Zo.rejected,e=>{e.fetchState="error"}).addCase(Zo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ec=Wg.reducer;function Jo(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 kc=require("react");function Rc(t,e){(0,kc.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 Yo=require("react"),Rs=require("react-redux");var Es=require("@reduxjs/toolkit");var Pc={data:null,fetchState:"idle"},ks=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},Re=(0,Es.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)}),Gg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),$g=(0,Es.createSlice)({name:"entities",initialState:Pc,reducers:{},extraReducers:t=>{t.addCase(Re.pending,e=>{e.fetchState="loading"}).addCase(Re.rejected,e=>{e.fetchState="error"}).addCase(Re.fulfilled,(e,o)=>{e.fetchState="done",e.data=Gg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(I,()=>Pc)}}),Ic=$g.reducer;var ri={};j(ri,{enUS:()=>Xg,nlNL:()=>Qg});var Xg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Qg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ac={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Dt=require("react/jsx-runtime"),Zg=({onCopy:t,onUse:e})=>{let o=(0,Yo.useRef)(null),n=S("EntitiesList",Ac),s=E(ri),r=(0,Rs.useSelector)(ks),i=(0,Rs.useDispatch)();return(0,Yo.useEffect)(()=>{i(Re())},[]),(0,Yo.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Dt.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Dt.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,Dt.jsx)(A.List,{children:r.map((a,l)=>(0,Dt.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Dt.jsx)("p",{className:n.empty,children:s("noResults")})]})},Lc=Zg;var Pe=require("react"),en=require("react-redux");var Ps=require("@reduxjs/toolkit");var Mc={data:null,fetchState:"idle"},Oc=t=>t.summary.data,Nc=t=>t.summary.fetchState==="error",We=(0,Ps.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),Jg=(0,Ps.createSlice)({name:"summary",initialState:Mc,reducers:{},extraReducers:t=>{t.addCase(We.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(We.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(We.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(I,()=>Mc)}}),Dc=Jg.reducer;var ii={};j(ii,{enUS:()=>Yg,nlNL:()=>em});var Yg={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."}]},em={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 Hc={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Ge=require("react/jsx-runtime"),tm=({onCopy:t})=>{let e=(0,Pe.useRef)(null),o=S("SummaryForm",Hc),[n,s]=(0,Pe.useState)(""),r=E(ii),i=(0,en.useSelector)(Oc),a=(0,en.useSelector)(Nc),l=(0,en.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(We())},[]),(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,Ge.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Ge.jsx)("p",{className:o.error,children:r("error")}):(0,Ge.jsxs)(Pe.Fragment,{children:[(0,Ge.jsx)("div",{className:o.main,children:(0,Ge.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,Ge.jsx)("div",{className:o.actions,children:(0,Ge.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Bc=tm;var ai={};j(ai,{enUS:()=>om,nlNL:()=>nm});var om={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},nm={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ht=T(require("react")),on=require("react-redux");var li={};j(li,{enUS:()=>sm,nlNL:()=>rm});var sm={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"}]},rm={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 Fc={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var mo=require("@reduxjs/toolkit");var ci={data:[],fetchState:"idle"},Kc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Uc=t=>t.answer.fetchState,fo=(0,mo.createAction)("answer/resetKnowledgeSearch"),go=(0,mo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),im=(0,mo.createSlice)({name:"answer",initialState:ci,reducers:{},extraReducers:t=>{t.addCase(go.pending,e=>{e.fetchState="loading"}).addCase(go.rejected,e=>{e.fetchState="error"}).addCase(go.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(I,()=>ci).addCase(fo,()=>ci)}}),zc=im.reducer;var tn=require("react/jsx-runtime"),jc=()=>(0,tn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,tn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,tn.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var oe=require("react/jsx-runtime"),am=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=ht.default.useState(""),{setSelected:i}=dt(),a=(0,ht.useRef)(null),l=S("EntitiesList",Fc),c=E(li),p=(0,on.useDispatch)(),d=(0,on.useSelector)(Kc),u=(0,on.useSelector)(Uc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(go({question:s,promptInstruction:n}))},f=(g,x)=>{p(ie({name:"knowledge assist source viewed",data:{question:x,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ht.useEffect)(()=>{var g;o&&u==="idle"?p(go({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,u]),(0,ht.useEffect)(()=>{u==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),(0,ht.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),(0,oe.jsxs)("div",{className:l.root,children:[d.length>0&&(0,oe.jsx)("div",{className:l.alignRight,children:(0,oe.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(A.ActionsBar,{list:d.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[d.map(({question:g,answer:x},w)=>(0,oe.jsx)(A.List,{children:(0,oe.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:x.answer,closeOnSelect:!0,onClick:()=>t(x.answer),onSourceClick:h=>f(h,g),sources:x.sources,styles:{title:l.question,description:l.answer},children:g})},`${x.answer}_${w}`)),u==="loading"&&(0,oe.jsx)("p",{className:l.status,children:c("loading")}),u==="error"&&(0,oe.jsx)("p",{className:l.status,children:c("error")}),(0,oe.jsxs)("form",{className:l.form,onSubmit:m,children:[(0,oe.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),(0,oe.jsx)("button",{type:"submit",className:l.submit,children:(0,oe.jsx)(jc,{})})]})]})]})},qc=am;var Is=require("@reduxjs/toolkit");var lm={data:null,fetchState:"idle"},ho=t=>t.profile.data,As=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],nn=(0,Is.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)}),cm=(0,Is.createSlice)({name:"profile",initialState:lm,reducers:{},extraReducers:t=>{t.addCase(nn.pending,e=>{e.fetchState="loading"}).addCase(nn.rejected,e=>{e.fetchState="error"}).addCase(nn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Vc=cm.reducer;var z=require("react/jsx-runtime"),pm=200,dm=5,um=4,gm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Wc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),mm=()=>{let t=(0,$e.useDispatch)(),e=he(),o=E(ai),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,$e.useSelector)(Rl),l=(0,$e.useSelector)(ho),[c,p]=(0,ne.useState)(null),[d,u]=(0,ne.useState)([]),[m,f]=(0,ne.useState)(),g=(0,$e.useSelector)(Ee),x=b("showSearch"),w=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),_=b("showImageSearch"),C=b("searchTriggerKey"),K=(0,$e.useSelector)(Tc),H=(0,$e.useSelector)(Pl),Le=(0,$e.useSelector)(kl),B=v=>dr(H.filter(L=>L.type===v.toUpperCase()),v),P=[{value:"PERSONAL",label:o("personalSuggestions"),list:B("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:B("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:B("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:B("IMAGE"),listOrientation:"horizontal",shouldShow:_}].filter(v=>v.shouldShow),J=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:w&&Wc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:h&&Wc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(X("knowledgeAssist")),shouldShow:y,experimental:!0}].filter(v=>v.shouldShow),ve=(K==null?void 0:K.map(v=>({value:v.code.toUpperCase(),label:`${v.name}s`,list:B(v.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],cr=(0,ne.useCallback)((0,Gc.default)((v,L)=>{t(Mt({query:v,type:L,tags:["search-overlay"]}))},pm),[]),wt=gm([...ve,...P]),au=(0,ne.useCallback)((v,L)=>{if(!L)return;let st=[...P,...ve].find(({value:Ut})=>Ut===L);st&&(t(X("edit")),p({...v,searchTerm:void 0}),u(st.list))},[t,c,ve]),pr=(0,ne.useCallback)((v,L)=>{switch(L.type){case"IMAGE":e.send(ti,{suggestion:L});break;default:e.send(Ve,{text:v,suggestion:L})}t(ae(!1))},[t]),lu=v=>{Jo(v.text),t(ie({name:"entity copied",data:{entity:v,type:"copy"}})),t(ae(!1))},cu=v=>{e.send(Ve,{text:v,suggestion:{source:"knowledge-assist",text:v}}),t(ie({name:"answer used",data:{originalText:v},options:{includeConversationData:!0}})),i(""),t(X("search")),t(fo()),t(ae(!1))},pu=v=>{Jo(v),t(ae(!1))},du=v=>{e.send(Ve,{text:v.text,suggestion:{source:"entity",text:v.text}}),t(ae(!1))},uu=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),gu=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function dr(v,L){return v.slice(0,m?10:L.toLowerCase()==="image"?um:dm)}function Vi(v,L,st){return L.reduce((Ut,vn)=>st&&m===st?vn.length+Ut:dr(vn,st).length+Ut,v)}function Kt(v){return L=>{n?window.confirm(o("warning"))&&(v(L),s(!1)):v(L)}}return(0,ne.useEffect)(()=>{r?cr(r,m):t(hs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(fo())},[a]),(0,ne.useEffect)(()=>{g&&t(Zo())},[g]),Rc(C,()=>t(ae(!0))),!x||!l?null:(0,z.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Kt(v=>t(ae(v))),onChangeType:v=>f(v),onChangePage:Kt(v=>t(X(v))),selectedType:m,search:r,page:a,isOpen:Le,types:[...ve,...P],children:[(0,z.jsx)(A.Page,{id:"search",children:(0,z.jsxs)(A.ActionsBar,{list:[...J.map(v=>({text:v.label,type:"command"})),...wt.map(v=>({text:v.text||v.url||v.message,type:v.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:v},L)=>pr(v,wt[L]),onSecondary:(v,L)=>{au(wt[L-J.length],wt[L-J.length].type)},children:[J.length>0&&(0,z.jsx)(A.List,{heading:o("commands"),children:J.map((v,L)=>(0,z.jsx)(A.ListItem,{index:Vi(L,[],"commands"),closeOnSelect:!1,onClick:v.onClick,isExperimental:v.experimental,children:v.label},v.label))}),[...ve,...P].map(({value:v,label:L,list:st,lineClamp:Ut,listOrientation:vn},mu)=>(0,z.jsx)(A.List,{heading:L,orientation:vn==="horizontal"?"horizontal":"vertical",children:dr(st,v).map((_e,fu)=>(0,z.jsx)(A.ListItem,{index:Vi(J.length+fu,[...ve,...P].slice(0,mu).map(({list:hu})=>hu),v),closeOnSelect:!1,lineClamp:Ut,onClick:()=>pr(_e.text,_e),description:v!=="IMAGE"?_e.title&&_e.text:void 0,children:v==="IMAGE"?(0,z.jsx)(A.Image,{title:_e.title||_e.text,src:_e.image}):_e.title||_e.text},`${_e.id}-${_e.text}`))},v))]})}),(0,z.jsx)(A.Page,{id:"edit",onDismiss:Kt(()=>{t(X("search")),p(null)}),children:c&&(0,z.jsx)(_s,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),u([])},onNext:gu,onPrevious:uu,onUse:v=>{t(X("search")),pr(v,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ae(!1)),u([]),p(null)}})}),(0,z.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Kt(()=>{t(X("search"))}),children:(0,z.jsx)(Lc,{onUse:du,onCopy:lu})}),(0,z.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Kt(()=>{t(X("search"))}),children:(0,z.jsx)(Bc,{onCopy:pu})}),(0,z.jsx)(A.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),isExperimental:!0,onDismiss:Kt(()=>{t(fo()),t(X("search"))}),children:(0,z.jsx)(qc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:cu,onResetQuestion:()=>{t(fo()),i("")}})})]})},$c=mm;var yo=require("react/jsx-runtime"),fm=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,yo.jsxs)(Xc.Fragment,{children:[t&&(0,yo.jsx)($c,{}),(0,yo.jsx)(yc,{}),e&&(0,yo.jsx)(Cc,{})]})},Qc=fm;var Xe=require("react-redux");function So(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 Ms=require("react");var op=require("interweave"),_o=require("react"),Ls=require("react-redux");var Zc=require("react");function Jc(t,e,o){(0,Zc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var hm=/[.*+?^${}()|[\]\\]/g,ym=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Sm(t){return t.replace(hm,"\\$&")}function vm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function _m(t){return t.search(ym)}function Yc(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Sm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function ep(t){return t.replace(Vt,'<mark data-type="placeholder">$1</mark>')}function vo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function xm(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 pi(t,e,o={}){if(e){let n=vm(e.toLowerCase(),t.toLowerCase()),s=vo(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=_m(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Ca).length>3||e.length>30?xm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${vo(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var tp={badge:"_badge_1syy2_1",formattedText:"_formattedText_1syy2_5"};var di=require("react/jsx-runtime"),Cm=["search","personal-collection-search","search-autocomplete"];function wm(t,e,o,n={}){let s="";return Cm.includes(e)?s=Yc(pi(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=pi(t,o,n),n.placeholders===!0&&(s=ep(s)),s}var Tm=()=>{},Em=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Ls.useSelector)(Gt),r=(0,Ls.useDispatch)(),i=S("TextSuggestion",tp),a=(0,_o.useRef)(null);(0,_o.useEffect)(()=>{let c=setTimeout(()=>{r(Ua({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),Jc(a,"click",()=>{r(Do(t)),r(we({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,_o.useMemo)(()=>wm(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"&&!n?null:(0,di.jsx)(O,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Tm,children:(0,di.jsx)(op.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},np=Em;var ui=require("react/jsx-runtime"),km=({suggestions:t,selectedIndex:e,reverse:o})=>{let n=(0,Ms.useMemo)(()=>{let s=t.map((r,i)=>(0,ui.jsx)(np,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return o?s.reverse():s},[t,e,o]);return(0,ui.jsx)(Ms.Fragment,{children:n})},Os=km;var sp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var sn=require("react/jsx-runtime"),Rm=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",sp),n=(0,Xe.useSelector)(So),s=(0,Xe.useDispatch)(),r=(0,Xe.useSelector)(Ee),i=(0,Xe.useSelector)(Wt),a=(0,Xe.useSelector)(bs),l=b("showTextSuggestions");return Yt(()=>{s(mt({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:(0,sn.jsx)("div",{className:o.root,"data-variant":"inline",children:(0,sn.jsx)("div",{className:o.paper,children:(0,sn.jsx)(ge,{children:(0,sn.jsx)(Os,{suggestions:t,selectedIndex:e})})})})},Pm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),rp=(0,Xe.connect)(Pm)(Rm);var Ds=T(require("classnames")),xo=require("react"),Ze=require("react-redux");var ip=require("react");function ap(t,e){let[o,n]=(0,ip.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)}}]}var cp=T(require("classnames")),Qe=require("react");var gi={};j(gi,{enUS:()=>Im,nlNL:()=>Am});var Im={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"}]}]},Am={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 lp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var yt=require("react/jsx-runtime"),mi=(t,e,o)=>n=>(0,yt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Lm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(gi),r=he(),i=S("Login",lp),a=b("productName"),l=(0,Qe.useCallback)(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=(0,Qe.useCallback)(g=>{g.preventDefault(),r.send(po,!0)},[e]),p=(0,Qe.useMemo)(()=>g=>(0,yt.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),d=(0,Qe.useCallback)(g=>(0,yt.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:u,hour:m,day:f}=(0,Qe.useMemo)(()=>({min:mi(i,60*10,l),hour:mi(i,60*60,l),day:mi(i,60*60*12,l)}),[]);return(0,yt.jsxs)("div",{className:(0,cp.default)(t,i.root),children:[s("loginPlease",{login:o?d:p,productName:a}),n&&(0,yt.jsxs)(Qe.Fragment,{children:[(0,yt.jsx)("br",{}),s("snooze",{min:u,hour:m,day:f})]})]})},Ns=Lm;var dp=require("react-redux");var pp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var rn=require("react/jsx-runtime"),Mm=({title:t})=>{let e=S("SearchTrigger",pp),o=(0,dp.useDispatch)();return(0,rn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,rn.jsx)(no,{}),(0,rn.jsx)("span",{className:e.text,children:t})]})},up=Mm;var fi={};j(fi,{enUS:()=>Om,nlNL:()=>Nm});var Om={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"}]},Nm={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 gp={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var N=require("react/jsx-runtime"),Dm=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",gp),n=E(fi),s=(0,Ze.useSelector)(So),r=Da(),i=(0,Ze.useDispatch)(),a=(0,xo.useRef)(null),l=b("searchTriggerKey"),c=b("productName"),p=(0,Ze.useSelector)(bs),d=(0,Ze.useSelector)(Ee),u=(0,Ze.useSelector)(Wt),[m,f]=(0,xo.useState)(null),g=b("showSearch"),x=b("showTextSuggestions"),w=b("adminUrl"),h=b("isEmbedded"),[y,_]=ap("dd-snooze-until-ms",0),C=p||y>Date.now(),K=t.filter(B=>B.source!=="gpt").length,H=()=>{C&&_(0),i(sc(!C))},Le=B=>{let P=Date.now()+B*1e3;_(P),k.info(`Snooze until: ${new Date(P)}`),i(mt({collapse:!0}))};return(0,xo.useEffect)(()=>{K===0&&f(null)},[t,K]),Yt(()=>{i(mt({collapse:!0,skipWhenInputFocus:!0}))}),d===null||u===!1?null:d===!1?(0,N.jsxs)("div",{ref:a,className:(0,Ds.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1}}),(0,N.jsx)("div",{className:o.triggersRight,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("collapse"),onClick:H,isCollapsed:!1})})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("open",{productName:c}),onClick:H,isCollapsed:!0})}),(0,N.jsx)("div",{className:o.collapsible,children:(0,N.jsx)(Ns,{loginUrl:w,isEmbedded:h,onSnooze:Le})})]}):!r||!s?null:(0,N.jsxs)("div",{ref:a,className:(0,Ds.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1},children:g&&(0,N.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(gs()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,N.jsx)(up,{title:n("search")})})}),(0,N.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,N.jsx)("div",{className:(0,Ds.default)(!m&&o.hintsHidden,o.hints),children:m}),(0,N.jsx)(Rt,{className:o.toggleButton,title:n("collapse"),onClick:H,isCollapsed:!1})]})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("open",{productName:c}),onClick:H,isCollapsed:!0})}),K>0&&x&&(0,N.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,N.jsx)(ge,{children:(0,N.jsx)(Os,{suggestions:t,selectedIndex:e,reverse:!0})})})]})},Hm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),mp=(0,Ze.connect)(Hm)(Dm);var fp=require("react-redux");var an=require("react/jsx-runtime"),Bm=({children:t})=>{let o=b("locale").replace("-","");return(0,an.jsx)(_r.Provider,{value:o,children:t})},Fm=({store:t,customStyles:e={},children:o})=>(0,an.jsx)(fp.Provider,{store:t,children:(0,an.jsx)(Bm,{children:(0,an.jsx)(ko.Provider,{value:e,children:o})})}),bo=Fm;var Xs=T(require("classnames")),Op=require("interweave"),et=require("react"),Np=require("react-redux");var hp=require("react"),Km=["div","span","mark","strong","b","i","u","em"];function hi(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(Km.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,hp.cloneElement)(n,{children:hi(i,e,o+1)})]}return[...t,...e]}function St(t){return t.tagName.toLowerCase()==="textarea"}var yp={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Ep=T(require("classnames")),kp=require("interweave"),Vs=require("react");function Sp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Hs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function vp(t){return t!=null}var Si=T(require("classnames")),ye=require("react");var Bs=require("react"),Um=["bottom","height","left","right","top","width"],zm=(t={},e={})=>Um.some(o=>t[o]!==e[o]),Je=new Map,_p,xp=()=>{let t=[],e=[];Je.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();zm(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Je.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),_p=window.requestAnimationFrame(xp)};function jm(t,e){return{observe(){let o=Je.size===0;if(Je.has(t)){let n=Je.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Je.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&xp()},unobserve(){let o=Je.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Je.delete(t),Je.size||cancelAnimationFrame(_p)}}}}function yi(t){let[e,o]=(0,Bs.useState)(null);return(0,Bs.useLayoutEffect)(()=>{if(!t.current)return;let n=jm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var Co=require("react"),Cp=require("react-dom");var bp={root:"_root_1jq08_1"};var wp=({children:t})=>{let[e,o]=(0,Co.useState)(null),n=(0,Co.useContext)(ko);return(0,Co.useLayoutEffect)(()=>{let s=document.createElement("div");return It(s),s.classList.add(bp.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?(0,Cp.createPortal)(t,e):null};var De={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 Fs=require("react/jsx-runtime"),Ks=(t=!1)=>{let[e,o]=(0,ye.useState)(t),n=(0,ye.useCallback)(()=>o(!0),[]),s=(0,ye.useCallback)(()=>o(!1),[]),r=(0,ye.useCallback)(()=>o(a=>!a),[]),i=(0,ye.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function vi(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 Us=({className:t,triggerRef:e,boundaryRef:o=(0,ye.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=vi,...a})=>{let l=yi(e),c=yi(o),p=(0,ye.useMemo)(()=>i(l,c,0),[l,c]);return(0,Fs.jsx)(wp,{children:(0,Fs.jsx)("div",{className:(0,Si.default)(De.ref,{[De.positionAbove]:n==="above",[De.positionBelow]:n==="below",[De.positionLeft]:n==="left",[De.positionRight]:n==="right",[De.alignStart]:s==="start",[De.alignCenter]:s==="center",[De.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Fs.jsx)("div",{className:(0,Si.default)(t,De.root),children:r})})})};var Tp=T(require("classnames")),zs=require("react");var _i=require("react/jsx-runtime"),js=(0,zs.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,zs.useRef)(null),r=S("TabCompletion",Fe);return(0,_i.jsx)("div",{ref:Hs([s,n]),className:(0,Tp.default)(t,r.popoverContentContainer),...o,children:(0,_i.jsx)("div",{className:r.popoverContent,children:e})})});var vt=require("react/jsx-runtime"),qm=t=>e=>{let o=vi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Vm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",Fe),i=Ks(),a=(0,Vs.useMemo)(()=>qm(t.getBoundingClientRect()),[t]),[l,c]=rs(t);return(0,Vs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,vt.jsxs)("span",{children:[(0,vt.jsx)("mark",{ref:Hs([l,i.triggerRef]),className:(0,Ep.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,vt.jsx)(Us,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,vt.jsx)(js,{style:o,children:(0,vt.jsx)("div",{className:r.hintText,children:s})})})]})},qs=class extends kp.Matcher{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${Sp(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(vp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,vt.jsx)(Vm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Gs=T(require("classnames")),Lp=require("interweave"),Z=require("react"),Mp=require("react-redux");var xi=require("react/jsx-runtime"),Rp=()=>(0,xi.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,xi.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 _t=require("react"),ln=require("react-redux"),Ip=T(require("lodash.debounce"));var Pp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Ws(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 bi(t){return t.replace("https://www.","").replace("https://","")}var Se=require("react/jsx-runtime"),Wm=3,Gm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),$m=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Wm})=>{let r=S("LinkSearch",Pp),[i,a]=(0,_t.useState)(""),l=(0,ln.useDispatch)(),c=(0,ln.useSelector)(Ul("url")),p=(0,ln.useSelector)(Il("URL",Gm)),[d,u]=(0,_t.useState)(p.length-1),m=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},g=(h,y)=>{h.stopPropagation(),h.preventDefault(),window.open(y,"_blank")},x=h=>{var C;let y=d-1<0?p.length-1:d-1,_=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(y),h.code==="ArrowDown"&&u(_),h.code==="Enter"&&t(((C=p[d])==null?void 0:C.text)||i)},w=(0,_t.useCallback)((0,Ip.default)(h=>{l(Mt({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,_t.useEffect)(()=>{i&&w(i)},[i]),(0,_t.useEffect)(()=>()=>{l(hs())},[]),(0,Se.jsxs)("div",{className:r.root,children:[(0,Se.jsx)(ge,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,y)=>(0,Se.jsx)(O,{selected:d===y,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,Se.jsxs)(D,{children:[(0,Se.jsx)(D.Image,{src:Ws(h,"small",m||void 0),title:h.title||h.text}),(0,Se.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,Se.jsx)(D.Title,{children:h.title||bi(h.text)}),h.title&&bi(h.text)]}),(0,Se.jsx)(O.Actions,{children:(0,Se.jsx)(O.ActionButton,{label:n,onClick:_=>g(_,h.text)})})]})},h.text))}),(0,Se.jsx)(Qo,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:x})]})},Ap=$m;var Ci={};j(Ci,{enUS:()=>Xm,nlNL:()=>Qm});var Xm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Qm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Q=require("react/jsx-runtime"),Zm=(0,Z.forwardRef)((t,e)=>{let o=S("TabCompletion",Fe);return(0,Q.jsx)("mark",{ref:e,className:(0,Gs.default)(o.matchSelection)},"selection-start")}),Jm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Ci),i=S("TabCompletion",Fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),d=(0,Mp.useDispatch)(),u=Ks(document.activeElement===n),[m]=(0,Z.useState)(()=>document.createRange());u.triggerRef.current=m,(0,Z.useEffect)(()=>()=>m.detach(),[]),(0,Z.useEffect)(()=>{let g=t.current,x=a.current;!g||!x||(m.setStart(g,0),m.setEnd(x,0))},[t.current,a.current]),Yt(()=>{u.close()});let f=(0,Z.useCallback)(g=>{let x=m.toString(),w=/^http(s?):\/\//.test(g)?g:`https://${g}`;d(Yn({text:`[${x}](${w})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,Gs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,Q.jsx)(Us,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,Q.jsxs)(js,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,Gs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,Q.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,Q.jsx)(Rp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Ap,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},$s=class extends Lp.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,Z.createRef)(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?(0,Q.jsx)(Zm,{ref:this.startRef}):(0,Q.jsx)(Jm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ye=require("react/jsx-runtime"),Ym=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=S("TabCompletion",yp),p=b("insertLink"),d=b("showMidSentenceSuggestions"),u=b("inlineSuggestions"),m=as(a),f=(0,et.useRef)(null);(0,et.useEffect)(()=>{St(a)&&m&&ls(a,m)},[m]);let g=(0,et.useCallback)(h=>{if(!s||!o)return h;let y=[(0,Ye.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Ye.jsx)("span",{"data-testid":"tab-completion",className:(0,Xs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push((0,Ye.jsx)("span",{className:(0,Xs.default)(c.hint,c.resetIndent),children:(0,Ye.jsx)(Un,{keyCode:"tab"},"tabHint")})),hi(h,y)},[s,o,n]),x=(0,et.useMemo)(()=>{let h=[];return p&&h.push(new $s("selection")),h.push(new Zt("placeholders")),r&&h.push(new qs("keywords")),h},[u,p,r]),w=(0,et.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,Ye.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[(0,Ye.jsx)(Op.Interweave,{tagName:"span",containerTagName:"div",className:(0,Xs.default)(c.container,c.agentText),disableLineBreaks:St(a),content:e||"\u200B",onAfterParse:g,matchers:x,selection:m,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!d}),(0,Ye.jsx)("br",{})]}):null},ef=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??vo(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:m,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&d!==!1}},Dp=(0,Np.connect)(ef)(Ym);var kd=T(require("classnames")),Rd=require("react"),V=require("react-redux");var xt=require("@reduxjs/toolkit");var Hp={list:[],fetchState:"idle",isInitialRequest:null},Fp=t=>t.autoflows.list||[],Bp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},tt=(0,xt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),wi=(0,xt.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(tt(t.platformSessionId))}),Ti=(0,xt.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(tt(t.platformSessionId))}),tf=(0,xt.createSlice)({name:"autoflows",initialState:Hp,reducers:{},extraReducers:t=>{t.addCase(wi.pending,(e,o)=>{let n=Bp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Ti.pending,(e,o)=>{let n=Bp(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(tt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(tt.rejected,e=>{e.fetchState="error"}),t.addCase(tt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(I,()=>Hp)}}),Kp=(0,xt.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(tt(t))}),s.on("sessionCompleted",()=>{o(tt(t))})}),Up=(0,xt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),zp=tf.reducer;var bt=require("@reduxjs/toolkit");var jp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},qp=t=>t.customMessages.list,Vp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Wp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Gp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),cn=(0,bt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Qs=(0,bt.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)}),Zs=(0,bt.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)}),$p=(0,bt.createSlice)({name:"customMessages",initialState:jp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(cn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Qs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Zs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Zs.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(I,()=>jp)}}),Xp=(0,bt.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($p.actions.onCustomMessage(r))})}),Qp=(0,bt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Zp=$p.reducer;var pn=require("@reduxjs/toolkit"),of={jwt:null,accountUrl:null,interval:null},Jp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Ei=(0,pn.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),ki=(0,pn.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Ei()),setInterval(()=>n(Ei()),o)}),Yp=(0,pn.createSlice)({name:"exchangeToken",initialState:of,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Ei.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(ki.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:ed}=Yp.actions,td=Yp.reducer;function od(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var dd=require("react"),ud=require("react-redux");var ld=T(require("classnames")),cd=require("react");var sd=T(require("classnames"));var nd={root:"_root_838fd_1"};var id=require("react/jsx-runtime"),nf=({className:t,children:e})=>{let o=S("Unicode",nd);return(0,id.jsx)("span",{className:(0,sd.default)(t,o.root),children:e})},rd=nf;var ad={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 Ri={};j(Ri,{enUS:()=>sf,nlNL:()=>rf});var sf={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"}]},rf={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"),lf=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",ad),a=E(Ri),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(O,{className:(0,ld.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,le.jsx)(D,{children:(0,le.jsxs)(D.Content,{children:[(0,le.jsxs)(D.Title,{children:[e&&(0,le.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,le.jsx)("span",{children:n})]})}),(0,le.jsx)(O.Actions,{fixed:e==="Started",children:(0,le.jsx)(O.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,le.jsxs)(cd.Fragment,{children:[(0,le.jsx)(rd,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},pd=lf;var Pi=require("react/jsx-runtime"),cf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},pf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Pi.jsx)(dd.Fragment,{children:t.map(s=>(0,Pi.jsx)(pd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||cf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),df=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},uf={onStartAutoflow:wi,onStopAutoflow:Ti},gd=(0,ud.connect)(df,uf)(pf);var Js=require("react"),fd=require("react-redux"),Li=T(require("classnames"));var Ii=require("react/jsx-runtime"),Ai=()=>(0,Ii.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Ii.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 md={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 He=require("react/jsx-runtime"),gf=({entities:t})=>{let e=S("EntitiesWidgetList",md),[o,n]=(0,Js.useState)(void 0),s=(0,fd.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Jo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Js.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,He.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,He.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,He.jsx)("span",{className:e.entityText,children:a.text}),(0,He.jsxs)("span",{className:e.iconWrapper,children:[(0,He.jsx)("span",{className:(0,Li.default)(e.icon),children:(0,He.jsx)(Ai,{})}),(0,He.jsx)("span",{className:(0,Li.default)(e.icon,o===l&&e.iconClicked),children:(0,He.jsx)(Ai,{})})]})]},a.text))})},hd=gf;var yd=T(require("classnames")),Mi=require("react"),Ht=require("react-redux");var dn={};j(dn,{enUS:()=>mf,nlNL:()=>ff});var mf={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"}]},ff={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 ot={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var se=require("react/jsx-runtime"),hf=({suggestion:t})=>{let e=E(dn),o=(0,Ht.useDispatch)(),n=(0,Ht.useSelector)(Vp(t.text)),s=(0,Ht.useSelector)(Wp(t.text)),r=(0,Ht.useSelector)(Gp(t.text)),i=(0,Ht.useSelector)(Vn),{replyOptions:a}=t,l=(0,Mi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Qs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Mi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(Zs({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(O,{onClick:l,className:(0,yd.default)(ot.root,{[ot.isUsed]:n,[ot.hasError]:r}),children:[(0,se.jsx)(D,{children:(0,se.jsxs)(D.Content,{children:[(0,se.jsxs)(D.Title,{className:ot.title,children:[t.text," ",(0,se.jsx)(zn,{className:ot.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:ot.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:ot.quickReplies,children:a.map(p=>(0,se.jsx)("li",{className:ot.quickReply,children:p.title},p.title))})]})}),(0,se.jsxs)(O.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(O.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,se.jsx)(O.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,se.jsx)(O.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Sd=hf;var Oi=require("react/jsx-runtime"),vd=()=>(0,Oi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Oi.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 bd=require("react-redux");var _d=require("react");var ce=require("react/jsx-runtime"),yf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=ys(s),i=E(dn),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},d=(0,_d.useCallback)(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return(0,ce.jsxs)(O,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ce.jsxs)(D,{children:[a&&t.image&&(0,ce.jsx)(D.Image,{src:Ws(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(D.Content,{children:[t.title&&(0,ce.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,ce.jsx)(O.Labels,{labels:t.searchKeywords}),(0,ce.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ce.jsxs)(O.Actions,{children:[r&&(0,ce.jsx)(O.ActionButton,{onClick:d,label:i("visitUrl")}),(0,ce.jsx)(O.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ce.jsx)(O.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},xd=yf;var un=require("react/jsx-runtime"),Sf=({contentType:t,lines:e,suggestions:o})=>{let n=he(),s=(0,bd.useSelector)(ro),r=a=>{n.send(Yr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ve,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,un.jsx)(un.Fragment,{children:o.map(a=>(0,un.jsx)(xd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Cd=Sf;var Ni={};j(Ni,{enUS:()=>vf,nlNL:()=>_f});var vf={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"}]},_f={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var wd={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 Di=require("react/jsx-runtime"),Td=()=>(0,Di.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Di.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 Hi=require("react/jsx-runtime"),Ed=()=>(0,Hi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Hi.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"),Ys=(t,e)=>{let o=(0,V.useSelector)(Ee);(0,Rd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},xf=()=>{let t=E(Ni),e=(0,V.useDispatch)(),o=b("isEmbedded"),n=S("Widget",wd),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,V.useSelector)(ho),d=(0,V.useSelector)(As),u=(0,V.useSelector)(Fp),m=(0,V.useSelector)(ks),f=(0,V.useSelector)(qp),g=(0,V.useSelector)(Wn),x=(0,V.useSelector)(Wt),w=(0,V.useSelector)(Ee),h=(0,V.useSelector)(Vn),y=(0,V.useSelector)(od),_=(0,V.useSelector)(ro),C=he(),K=(0,V.useSelector)(jl),H=(0,V.useSelector)(Jp("/admin/personal-collection")),Le=b("adminUrl");if(Ys(()=>(e(cn(h)),e(Xp(h)),()=>{e(Qp(h))}),[e,x,r,h]),Ys(()=>(e(tt(h)),e(Kp(h)),()=>{e(Up(h))}),[e,x,s,h]),Ys(()=>{d.forEach(({type:P})=>{e(P==="entities"?Re():je(P))})},[e,x,g,p]),Ys(()=>(e(ki()),()=>{e(ed())}),[e,x,i,g]),x===!1)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(w===!1)return(0,R.jsx)("div",{className:n.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Ns,{isEmbedded:o,loginUrl:Le})})},"login");if(!p||!h||w===null||K||y)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("waiting")})})},"waiting");let B=c||a||l||H;return(0,R.jsx)("div",{className:(0,kd.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(jn,{className:n.sectionList,children:[B&&(0,R.jsx)(rt,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:n.shortcutList,children:[c&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(no,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Ed,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(Td,{}),t("linkKnowledgeSearch")]}),H&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:H,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,R.jsx)(vd,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&(0,R.jsx)(rt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(ge,{withDivider:!0,children:f.map(P=>(0,R.jsx)(Sd,{suggestion:P},P.text))})}),s&&u.length>0&&(0,R.jsx)(rt,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(ge,{withDivider:!0,children:(0,R.jsx)(gd,{})})}),d.map(({type:P,title:J,amount:ve,lines:cr})=>{var wt;switch(P){case"entities":return m&&m.length>0&&(0,R.jsx)(rt,{type:P,title:J,"data-testid":`type-${P}`,children:(0,R.jsx)(hd,{entities:m})},P);default:return((wt=_[P])==null?void 0:wt.fetchState)==="done"&&_[P].suggestions.length>0&&(0,R.jsx)(rt,{type:P,title:J,"data-testid":`type-${P}`,children:(0,R.jsx)(ge,{withDivider:!0,children:(0,R.jsx)(Cd,{lines:cr,contentType:P,suggestions:_[P].suggestions.slice(0,ve)||[]})})},P)}})]})})},Pd=xf;function wo(t){let e=new Range;return e.selectNodeContents(t),e}function Id(t,e,o){try{return Ct(t,e,o),!0}catch{return!1}}function er(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function tr(t){return"tagName"in t&&t.tagName==="BR"}var gn=/[\u200B-\u200D\uFEFF]/g;function Ct(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){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(gn,""),d=s+p.length,u=e>=s&&e<=d,m=o>=s&&o<=d;if(u){let f=i(c,e-s);f===0&&!m?n.setStartBefore(l):n.setStart(l,f)}m&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(tr(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;er(l)&&c&&!er(c)&&!tr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function mn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,m=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(gn,"").length),m&&(l=c+f.substring(0,r).replace(gn,"").length),c+=f.replace(gn,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;tr(d)&&!f&&c++;for(let g=0;g<d.childNodes.length;g++){let x=u&&g===n,w=m&&g===r;if(x&&(a=c),w&&(l=c),l!==void 0||((!x||!i)&&p(d.childNodes[g]),m&&g===r-1&&(l=c),l!==void 0))break}!m&&er(d)&&!f&&c++,m&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function fn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,m=d?r:void 0,f=c.textContent.replace(gn,"");u===0&&m===void 0?a+=f:a+=f.substring(u,m);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&tr(c)&&!u&&(a+=`
3
+ `,kt.MISSING_INTL_API,i);var _=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));y=p.options[_]||p.options.other}if(!y)throw new Sr(p.value,u,Object.keys(p.options),i);a.push.apply(a,Lo(y.value,e,o,n,s,u-(p.offset||0)));continue}}return Lu(a)}function Ou(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 Nu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=Ou(t[n],e[n]),o},re({},t)):t}function vr(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function Du(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Hn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,En([void 0],o,!1)))},{cache:vr(t.number),strategy:Bn.variadic}),getDateTimeFormat:Hn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,En([void 0],o,!1)))},{cache:vr(t.dateTime),strategy:Bn.variadic}),getPluralRules:Hn(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,En([void 0],o,!1)))},{cache:vr(t.pluralRules),strategy:Bn.variadic})}}var sa=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,m){return!u.length||m.type!==W.literal||typeof u[u.length-1]!="string"?u.push(m.value):u[u.length-1]+=m.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Lo(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Qi(i,["formatters"]);this.ast=t.__parse(e,re(re({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Nu(t.formats,n),this.formatters=s&&s.formatters||Du(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=Yi,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 Hu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var Bu="dummy",_r=(0,Fn.createContext)(null);function E(t){let e=(0,Fn.useContext)(_r);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=Hu(o,n);return r?new sa(r).format(s):(e!==Bu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var xr={};j(xr,{enUS:()=>Fu,nlNL:()=>Ku});var Fu={experimental:[{type:0,value:"Experimental"}]},Ku={experimental:[{type:0,value:"Experimenteel"}]};var br=require("react/jsx-runtime"),ra=({children:t})=>{let e=S("Chip",Xi);return(0,br.jsx)("span",{className:e.root,children:t})},Kn=()=>{let t=E(xr);return(0,br.jsx)(ra,{children:t("experimental")})},ia=ra;var la=T(require("classnames"));var aa={root:"_root_cq1yq_1"};var ca=require("react/jsx-runtime");var Uu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},zu=({className:t,keyCode:e,...o})=>{let n=S("KeyboardHint",aa);return(0,ca.jsx)("span",{"data-key":Uu[e],className:(0,la.default)(t,n.root),...o})},Un=zu;var da=T(require("classnames"));var pa={root:"_root_4a08n_1"};var ua=require("react/jsx-runtime"),ju=({className:t,children:e,...o})=>{let n=S("Label",pa);return(0,ua.jsx)("span",{...o,className:(0,da.default)(t,n.root),children:e})},zn=ju;var ga={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};var jt=require("react/jsx-runtime"),qu=({title:t,children:e,type:o,...n})=>{let s=S("Section",ga);return(0,jt.jsxs)("section",{...n,className:s.root,"data-section-type":o,children:[t&&(0,jt.jsx)("div",{className:s.subTitleContainer,children:(0,jt.jsx)("span",{className:s.subtitle,children:t})}),(0,jt.jsx)("div",{className:s.suggestions,children:e})]})},rt=qu;var fa=T(require("classnames")),ha=T(require("react"));var ma={root:"_root_19wxp_1"};var ya=require("react/jsx-runtime"),Vu=ha.default.forwardRef(({className:t,children:e},o)=>{let n=S("SectionList",ma);return(0,ya.jsx)("div",{ref:o,className:(0,fa.default)(n.root,t),children:e})}),jn=Vu;var Mo=T(require("classnames")),ue=T(require("react"));var Cr={root:"_root_fsa1k_10",fadein:"_fadein_fsa1k_1",isClickable:"_isClickable_fsa1k_45",isSelected:"_isSelected_fsa1k_50",actions:"_actions_fsa1k_74",actionsIsFixed:"_actionsIsFixed_fsa1k_96",actionButton:"_actionButton_fsa1k_104",dropdownList:"_dropdownList_fsa1k_125",dropdownButton:"_dropdownButton_fsa1k_140",dropdownItem:"_dropdownItem_fsa1k_150",dropdownItemButton:"_dropdownItemButton_fsa1k_159",actionButtonIsPrimary:"_actionButtonIsPrimary_fsa1k_173",actionButtonIsDisabled:"_actionButtonIsDisabled_fsa1k_177",labels:"_labels_fsa1k_185",label:"_label_fsa1k_185"};var de=require("react/jsx-runtime"),qt=(0,ue.createContext)(Cr),Wu=({fixed:t,children:e,...o})=>{let n=(0,ue.useContext)(qt);return(0,de.jsx)("div",{...o,className:(0,Mo.default)(n.actions,{[n.actionsIsFixed]:t}),children:e})},Gu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=(0,ue.useContext)(qt);return(0,de.jsxs)("div",{className:(0,Mo.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})]})},$u=({index:t,label:e,onClick:o})=>{let n=(0,ue.useContext)(qt);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})})},Xu=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=(0,ue.useContext)(qt);return(0,de.jsx)("button",{type:"button",className:(0,Mo.default)(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},wr=({labels:t})=>{let e=(0,ue.useContext)(qt);return(0,de.jsx)("div",{className:e.labels,children:t.map(o=>(0,de.jsx)("span",{className:e.label,children:o},o))})},Vt=ue.default.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=S("Suggestion",Cr),l=(0,ue.useCallback)(c=>{c.preventDefault(),o&&o(c)},[o]);return(0,de.jsx)(s,{...r,ref:i,className:(0,Mo.default)(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:(0,de.jsx)(qt.Provider,{value:a,children:n})})});Vt.Labels=wr;Vt.Actions=Wu;Vt.ActionButton=Xu;Vt.DropdownButton=Gu;Vt.DropdownItem=$u;var O=Vt;var va=T(require("classnames"));var Sa={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};var _a=require("react/jsx-runtime"),Qu=({withDivider:t,children:e})=>{let o=S("SuggestionList",Sa);return(0,_a.jsx)("div",{"data-testid":"suggestions-overlay-list",className:(0,va.default)(o.root,{[o.isWithDivider]:t}),children:e})},ge=Qu;var ba=T(require("classnames"));var xa={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};var qn=require("react/jsx-runtime"),Zu=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=S("ToggleButton",xa);return(0,qn.jsx)("button",{type:"button",className:(0,ba.default)(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:(0,qn.jsx)("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:(0,qn.jsx)("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},Rt=Zu;var Ca=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,Wt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var wa=/x-deepdesk-(([a-z0-9\-_])+-version)/,be=(g=>(g.SEARCH="search",g.TEMPLATE="template",g.ELASTIC_SEARCH="search-autocomplete",g.GPT="gpt",g.TRIE="trie",g.TRIE_WITH_TYPOS="trie-with-typos",g.SEMANTIC="semantic",g.TEXT_RECOMMENDATION="text_recommendation",g.URL_RECOMMENDATION="url_recommendation",g.LINK_RECOMMENDATION="link_recommendation",g.PERSONAL_COLLECTION="personal-collection",g.PERSONAL_COLLECTION_SEARCH="personal-collection-search",g.SEARCH_OVERLAY="search-overlay",g.SEARCH_PREVIEW="search-preview",g.SEARCH_URL="search-url",g))(be||{}),it=(r=>(r.ENTER="enter",r.TAB="tab",r.ARROW="arrow",r.HOTKEY="hotkey",r.MOUSE="mouse",r))(it||{});var Ae=require("react-dom");var Xc=require("react");var Ta=require("@reduxjs/toolkit"),Ea=require("react-redux");var Oo=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(Oo||{});var Ju={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"},ka=(0,Ta.createSlice)({name:"settings",initialState:Ju,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:No}=ka.actions,Tr=t=>e=>e.settings[t],b=t=>(0,Ea.useSelector)(Tr(t)),Ra=ka.reducer;var hc=require("react"),go=require("react-redux");var Me=require("@reduxjs/toolkit"),Ma=require("diff"),Oa=require("react-redux");function Pa(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function at(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)=>at(r,e[i],o-1)):Pa(t)&&Pa(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>at(t[i],e[i],o-1)):!1}function Yu(t){return Math.max(...t.map(e=>e.length))}function eg(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 Ia(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Yu(n);s++){let r=eg(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 tg=2;function Er(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=Ia(t,tg);return o&&o.text!==e?o:t[0]}var Ce=require("@reduxjs/toolkit"),Aa={current:null,isSupported:null},I=(0,Ce.createAction)("resetConversation"),Vn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Wn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Gt=t=>t.conversation.isSupported,kr=(0,Ce.createAsyncThunk)("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Gn=(0,Ce.createAsyncThunk)("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),$n=(0,Ce.createAsyncThunk)("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Xn=(0,Ce.createAsyncThunk)("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Wn(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),Rr=(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})})}),Qn=(0,Ce.createAsyncThunk)("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Wn(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),og=[Gn.rejected,$n.rejected,Xn.rejected,Qn.rejected].map(t=>t==null?void 0:t.toString()),ng=(0,Ce.createSlice)({name:"conversation",initialState:Aa,reducers:{},extraReducers:t=>{t.addCase(kr.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Gn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase($n.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Rr.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Xn.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Qn.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(I,()=>Aa).addMatcher(e=>og.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),La=ng.reducer;var lt={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Jn(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 Yn=(0,Me.createAction)("input/replaceText"),es=(0,Me.createAction)("input/keyDown"),Pt=(0,Me.createAction)("input/sendMessage"),ts=(0,Me.createAction)("input/sendEditSuggestionMessage"),os=(0,Me.createAction)("input/uiInputChange"),ns=(0,Me.createAction)("input/applyImageSuggestion"),ie=(0,Me.createAction)("input/sendEvent");function Zn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i,searchTerm:a,text:l},eventMetrics:{inputType:c},replace:p}=t.stagedSuggestion,d=o==="search"||o==="personal-collection-search",u=e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);(d||p==="selection")&&(u=e),t.stagedSuggestion.suggestion.source==="search-overlay"&&(u=l),t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:u,source:o,abVariant:n,abTestName:s,inputType:c,sourceText:i,trainingJobs:r||[],searchTerm:d?t.userCommitted.text:a}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var Na=t=>(0,Me.createSlice)({name:t,initialState:lt,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,{...lt,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=Er(e.textSuggestions,e.userCommitted.text)},changeSelection(e,o){o.payload&&(at(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Zn(e)))},platformInput(e,o){let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end),e.text=n,e.html=s||null},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:m,altKey:f}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:g}=e,{text:x}=o.payload,w=(0,Ma.diffChars)(g,x);g.length-x.length>1&&e.metrics.deletions.push(...w.filter(h=>h.removed).map(h=>h.value)),e.metrics.numCharsDeleted+=g.length-x.length;break}case"C":case"V":case"X":if(!u&&!m){e.metrics.numCharsTyped+=1;let g=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}break;case"Shift":break;default:if(!u&&!m&&!f){e.metrics.numCharsTyped+=1;let g=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;g&&g.length>0&&(e.metrics.numCharsDeleted+=g.length,e.metrics.deletions.push(g))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=lt.metrics,e.textSuggestions=[],e.stagedSuggestion=null),e.text!==o.payload.text&&Zn(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"&&Zn(e)},commitSuggestion(e){Zn(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=Er(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){let n=o.agentStartedTypingTimestamp!=null?o.agentStartedTypingTimestamp:Date.now(),s=(Date.now()-n)/1e3;e.metrics.externalTimeTotalSeconds=s,e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)}},extraReducers:e=>{e.addCase(I,o=>{o.tabCompletionSuggestion=lt.tabCompletionSuggestion,o.previousKeyDownEvent=lt.previousKeyDownEvent,o.textSuggestions=lt.textSuggestions,o.selectedSuggestionIndex=lt.selectedSuggestionIndex,o.metrics=lt.metrics})}}),Pr=Na("input"),$t=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),sg=t=>t.input.selection,Da=()=>(0,Oa.useSelector)(sg),{userInput:Ha,changeSelection:Ir,initialInput:Ba,mergeMetrics:Fa,nextTextSuggestionIndex:Ka,offeredTextSuggestion:Ua,previousTextSuggestionIndex:za,registerCut:ja,registerKeyDown:qa,registerPaste:Va,reset:Wa,resetToCommitted:Do,platformInput:Ga,setSelectedTextSuggestionIndex:It,setTextSuggestions:Oe,stageSuggestion:we,commitSuggestion:ct}=Pr.actions,Y=Na("overlay");var Xt=require("react");var $a={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};var Ar=require("react/jsx-runtime"),rg=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=(0,Xt.useRef)(null),l=(0,Xt.useRef)(null),c=S("Dialog",$a);return(0,Xt.useEffect)(()=>{var u,m;let p=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},d=f=>{let g=window.getSelection();g!=null&&g.toString()||f.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(m=a.current)==null||m.addEventListener("keyup",p),()=>{var f,g;(f=a.current)==null||f.removeEventListener("click",d),(g=a.current)==null||g.removeEventListener("keyup",p)}},[a,l,s,n]),(0,Xt.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,Ar.jsx)("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:(0,Ar.jsx)("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},Qt=rg;var Qr=require("react"),vs=require("react-redux");var Lr={};j(Lr,{enUS:()=>ig,nlNL:()=>ag});var ig={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?"}]},ag={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 Xa={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 Ho=require("react/jsx-runtime"),ss=()=>(0,Ho.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[(0,Ho.jsx)("title",{id:"angleLeftTitle",children:"AngleLeft"}),(0,Ho.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 Bo=require("react/jsx-runtime"),Qa=()=>(0,Bo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[(0,Bo.jsx)("title",{id:"angleRightTitle",children:"AngleRight"}),(0,Bo.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 me=require("react"),gl=require("react-redux"),ml=require("interweave"),zr=T(require("classnames"));var Mr={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 Ja=require("interweave"),Ya=T(require("classnames"));var Zt=require("react");function Za(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function rs(t){let e=(0,Zt.useRef)(null),[o,n]=(0,Zt.useState)(!1);return(0,Zt.useEffect)(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Za((p,d)=>{let u=e.current;if(!u)return;let m=p/r,f=d/r,g=u.getBoundingClientRect(),x=m>g.x&&m<g.x+g.width&&f>g.y&&f<g.y+g.height;x&&!s?(s=!0,n(!0)):!x&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Za(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var Fe={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Or=require("react/jsx-runtime"),lg=({inputElement:t,children:e})=>{let o=S("TabCompletion",Fe),[n,s]=rs(t);return(0,Or.jsx)("mark",{ref:n,className:(0,Ya.default)(o.matchPlaceholder,{[o.hover]:s}),children:e})},Jt=class extends Ja.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,Or.jsx)(lg,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Yt=require("react");function is(t){return t.contentEditable==="true"}function cg(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 el(t){let{selectionStart:e,selectionEnd:o}=is(t)?cg(t):t;return[e,o]}function as(t){let[,e]=(0,Yt.useState)(),o=(0,Yt.useRef)(null);return o.current=el(t),(0,Yt.useEffect)(()=>{let n=()=>{let[s,r]=o.current??[],i=el(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function ls(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(Wt);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 tl=require("react");function eo(t){(0,tl.useEffect)(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function At(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var ol,Ne=new Map,pg=["bottom","height","left","right","top","width"],dg=(t={},e={})=>pg.some(o=>t[o]!==e[o]);function nl(t){var o,n;let e=((n=(o=t.ownerDocument)==null?void 0:o.defaultView)==null?void 0:n.frameElement)??null;return e?[e,...nl(e)]:[]}function sl(t,e){return!t||!e?null:{...t,top:t.top+e.top,left:t.left+e.left}}var Nr=!1,rl=()=>{Nr=!0;let t=[];Ne.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),Ne.delete(o);return}let n=o.getBoundingClientRect();dg(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{let o=e.parentRects?e.parentRects.reduce(sl,e.rect):e.rect;e.callbacks.forEach(n=>n(o))}),Ne.size!==0&&(ol=window.requestAnimationFrame(rl))};function Dr(t,e){let o=nl(t),n=[],s=o.map((r,i)=>Dr(r,a=>{n[i]=a;let l=Ne.get(t);if(!l)return;let c=n.reduce(sl,l.rect);l.callbacks.forEach(p=>p(c))}));return{observe(r=!0){if(s.forEach(i=>i.observe(!1)),Ne.has(t)){let i=Ne.get(t);i.callbacks.push(e),i.rect&&e(i.rect)}else Ne.set(t,{rect:void 0,callbacks:[e],parentRects:n});r&&!Nr&&rl()},unobserve(){s.forEach(i=>i.unobserve());let r=Ne.get(t);if(r){let i=r.callbacks.indexOf(e);i>=0&&r.callbacks.splice(i,1),r.callbacks.length||Ne.delete(t),Ne.size||(cancelAnimationFrame(ol),Nr=!1)}}}}var il,De=new Map,al=()=>{De.forEach((t,e)=>{if(!e.isConnected){De.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)))}),De.size!==0&&(il=window.requestAnimationFrame(al))};function ll(t,e){return{observe(){let o=De.size===0;De.has(t)?De.get(t).callbacks.push(e):De.set(t,{visible:void 0,callbacks:[e]}),o&&al()},unobserve(){let o=De.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||De.delete(t),De.size||cancelAnimationFrame(il)}}}}var Hr=["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 Br(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function to(t){return parseFloat(t)}function cs(t){return Math.round(t*1e6)}function cl(t){return t/1e6}function Fr(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=to(t.width),r=to(t.borderLeftWidth),i=to(t.borderRightWidth),a=to(t.paddingRight),l=cl(cs(s)-cs(r)-cs(i)),c=cl(cs(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function Lt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position=e.position??"fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",At(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};Br(n,o,Hr),Fr(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ll(t,()=>{Br(n,o,Hr),Fr(n,t,o),r(),setTimeout(r,0)}),a=Dr(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(Br(n,o,Hr),Fr(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=to(d.borderTopWidth),m=to(d.borderBottomWidth),f=p.top+u-c.top,g=c.top+c.height+-(p.top+p.height-m);o.style.clipPath=`inset(${f}px 0px ${g}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Kr={};j(Kr,{enUS:()=>ug,nlNL:()=>gg});var ug={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"}]},gg={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 Fo=require("react/jsx-runtime"),pl=()=>(0,Fo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[(0,Fo.jsx)("title",{id:"circleCheckTitle",children:"Check"}),(0,Fo.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 Ur=require("react/jsx-runtime"),dl=()=>(0,Ur.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:(0,Ur.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"})});function mg(t){let e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!n}function ps(t){return t?t instanceof ShadowRoot?ps(t.host):t===t.ownerDocument.body?t.ownerDocument:mg(t)?t:ps(t.parentNode):document.body}var ul=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(ul||{}),Ke=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentCaret=null;currentSelection={start:0,end:0};currentHTML="";isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e}),n&&(this.currentSelection=this.getSelection()),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e}),this.triggerCaretPosition(),this.currentHTML=o))}triggerSelection(){let e=this.getSelection();(e.start!==this.currentSelection.start||e.end!==this.currentSelection.end)&&(this.currentSelection=e,this.emit("selection",e),this.triggerCaretPosition())}triggerCaretPosition(){let e=this.getCaretPosition();at(e,this.currentCaret)||(this.currentCaret=e,this.emit("caret",e))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange(),this.triggerSelection()}handleClick(){this.triggerSelection()}handleFocus(){this.isFocused||this.emit("focus"),this.triggerSelection(),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(ul).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){var n,s;let o=((n=e.clipboardData)==null?void 0:n.getData("text"))||((s=e.clipboardData)==null?void 0:s.getData("text/plain"))||"";this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",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)),this.addEventListener("click",()=>this.triggerSelection()),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let e=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});e.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{e.disconnect()});let o=ps(this.element);if(o){let n=()=>{this.currentCaret!==null&&(this.currentCaret=null,this.emit("caret",null))};o.addEventListener("scroll",n),this.disposeHandlers.push(()=>{o.removeEventListener("scroll",n)})}this.currentSelection=this.getSelection()}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 Ue=class extends Ke{lastKnownSelection=null;getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){let e=this.getSelection();return e?this.getText().slice(e.start,e.end):""}getCaretPosition(){return null}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};var ee=require("react/jsx-runtime"),fg=({value:t,onUse:e,...o})=>{var p;let n=E(Kr),s=(0,gl.useDispatch)(),r=S("EditSuggestionTextInput",Mr),[i,a]=(0,me.useState)(null),l=(0,me.useRef)(null),c=((p=t.match(Wt))==null?void 0:p.length)||0;return(0,me.useEffect)(()=>{let d;return l.current&&(a(l.current),d=new Ue(l.current),d.on("change",({plainText:u})=>{s(Y.actions.userInput({text:u,selection:d.getSelection()}))}),d.on("keydown",u=>{s(Y.actions.registerKeyDown(Jn(u))),u.code==="Enter"&&u.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:u,selectionText:m})=>{s(Y.actions.registerPaste({text:u,selectionText:m}))}),d.on("cut",({selectionText:u})=>{s(Y.actions.registerCut(u))})),()=>{s(Y.actions.reset()),d.dispose(),d.deactivate()}},[l]),(0,me.useEffect)(()=>{t&&l.current&&(l.current.value=t)},[t,l]),(0,me.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,ee.jsxs)("div",{className:r.textInputWrapper,children:[(0,ee.jsx)("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&(0,ee.jsx)(hg,{inputElement:l.current,value:t}),(0,ee.jsxs)("div",{className:(0,zr.default)(r.alert,c===0?r.success:r.warning),children:[(0,ee.jsx)("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?(0,ee.jsx)(pl,{}):(0,ee.jsx)(dl,{})]})]})},hg=({inputElement:t,value:e})=>{let o=S("EditSuggestionTextInput",Mr),n=(0,me.useRef)(null),s=as(t);return(0,me.useEffect)(()=>{ls(t,s)},[s,t]),(0,ee.jsx)(yg,{inputElement:t,children:(0,ee.jsxs)("div",{ref:n,className:(0,zr.default)(o.root,o.agentText),children:[(0,ee.jsx)(ml.Interweave,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new Jt("placeholders")],inputElement:t,boundaryRef:n}),(0,ee.jsx)("br",{})]})})},yg=({inputElement:t,children:e})=>{let o=(0,me.useRef)(null);return(0,me.useEffect)(()=>{if(!o.current)return()=>{};let[n,s]=Lt(t,{overlayContainer:o.current,mirrorOverflow:!0});return n.setAttribute("translate","no"),()=>{s()}},[o.current]),(0,ee.jsx)("div",{ref:o,children:e})},fl=fg;var ro=require("react");var hl=require("react"),ds=T(require("classnames"));var te={root:"_root_185k9_1",list:"_list_185k9_2",listWrapper:"_listWrapper_185k9_6",listHorizontal:"_listHorizontal_185k9_10",page:"_page_185k9_19",search:"_search_185k9_25",pageNav:"_pageNav_185k9_33",pageTitle:"_pageTitle_185k9_41",pageBackButton:"_pageBackButton_185k9_48",listHeading:"_listHeading_185k9_62",listItem:"_listItem_185k9_70",listItemContent:"_listItemContent_185k9_79",listItemText:"_listItemText_185k9_97",listItemDescription:"_listItemDescription_185k9_105",truncate:"_truncate_185k9_112",lineClamp:"_lineClamp_185k9_118",listItemTitle:"_listItemTitle_185k9_125",listItemAction:"_listItemAction_185k9_132",listItemPrimaryAction:"_listItemPrimaryAction_185k9_146",listItemSelected:"_listItemSelected_185k9_151",sources:"_sources_185k9_155",sourcesTitle:"_sourcesTitle_185k9_162",source:"_source_185k9_155",icon:"_icon_185k9_177",searchIcon:"_searchIcon_185k9_194",searchInputWrapper:"_searchInputWrapper_185k9_199",searchInput:"_searchInput_185k9_199",select:"_select_185k9_220",selectType:"_selectType_185k9_237",selectWrapper:"_selectWrapper_185k9_241",image:"_image_185k9_271",imageSrc:"_imageSrc_185k9_278",imageSrcHidden:"_imageSrcHidden_185k9_289",imageSrcStatus:"_imageSrcStatus_185k9_293",imageTitle:"_imageTitle_185k9_303",actions:"_actions_185k9_308",actionsWrapper:"_actionsWrapper_185k9_312",actionsBar:"_actionsBar_185k9_318",actionButton:"_actionButton_185k9_327",actionShortcut:"_actionShortcut_185k9_345",actionShortcutFixKerning:"_actionShortcutFixKerning_185k9_352"};var Mt={};j(Mt,{enUS:()=>Sg,nlNL:()=>vg});var Sg={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}]},vg={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}]};var pt=require("react/jsx-runtime"),_g=({src:t,title:e})=>{let o=S("CommandPalette",te),[n,s]=(0,hl.useState)("loading"),r=E(Mt);return(0,pt.jsxs)("div",{className:o.image,children:[(0,pt.jsx)("img",{src:t,alt:e,onLoad:()=>s("done"),onError:()=>s("error"),className:(0,ds.default)(o.imageSrc,{[o.imageSrcHidden]:["loading","error"].includes(n)})}),n==="loading"&&(0,pt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:r("loading")}),n==="error"&&(0,pt.jsx)("span",{className:(0,ds.default)(o.imageSrc,o.imageSrcStatus),children:(0,pt.jsx)(bn,{})}),e&&(0,pt.jsx)("span",{className:o.imageTitle,children:e})]})},yl=_g;var Sl=T(require("react")),vl=T(require("classnames"));var Ko=require("react/jsx-runtime");function jr({children:t,heading:e,orientation:o}){let n=S("CommandPalette",te);return Sl.default.Children.count(t)===0?null:(0,Ko.jsxs)("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&(0,Ko.jsx)("h4",{className:n.listHeading,children:e}),(0,Ko.jsx)("div",{className:(0,vl.default)(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}var Uo=T(require("classnames"));var us=T(require("react")),bl=require("react/jsx-runtime"),_l=us.default.createContext(void 0);function dt(){let t=us.default.useContext(_l);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var xl=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=us.default.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return(0,bl.jsx)(_l.Provider,{value:i,children:t})};var fe=require("react/jsx-runtime");function qr({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}=dt(),m=S("CommandPalette",te);function f(g){n(g),t&&u(!1)}return(0,fe.jsxs)("div",{className:(0,Uo.default)(m.listItem,d===r&&m.listItemSelected),children:[(0,fe.jsxs)("button",{type:"button",className:(0,Uo.default)("command-palette-list-item",m.listItemAction,m.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:f,...p,children:[(0,fe.jsxs)("div",{className:m.listItemContent,children:[typeof o=="string"?(0,fe.jsx)("p",{className:(0,Uo.default)(m.listItemText,m.truncate,c==null?void 0:c.title),children:o}):o,a&&(0,fe.jsx)("p",{className:(0,Uo.default)(m.listItemDescription,c==null?void 0:c.description,e?m.lineClamp:m.truncate),children:a})]}),i&&(0,fe.jsx)(Kn,{})]}),l&&(0,fe.jsxs)("div",{className:m.sources,children:[(0,fe.jsx)("span",{className:m.sourcesTitle,children:"Sources"}),l.map(g=>g.url?(0,fe.jsx)("a",{className:m.source,href:g.url,target:"_blank",title:g.url,rel:"noopener noreferrer",onClick:()=>s&&s(g),children:g.name},g.url):(0,fe.jsx)("span",{className:m.source,children:g.name},g.name))]})]})}var ut=require("react/jsx-runtime");function Vr({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=E(Mt),i=S("CommandPalette",te),{page:a}=dt();return a!==o?null:(0,ut.jsxs)("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&(0,ut.jsxs)("div",{className:i.pageNav,children:[(0,ut.jsxs)("button",{className:i.pageBackButton,type:"button",onClick:n,children:[(0,ut.jsx)(ss,{}),r("back")]}),e&&(0,ut.jsx)("h3",{className:i.pageTitle,children:e}),s&&(0,ut.jsx)(Kn,{})]}),t]})}var gt=require("react");var gs=()=>/Mac/i.test(navigator.platform);var fs=require("@reduxjs/toolkit");var xg={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},k=xg;var oo=require("@reduxjs/toolkit");function bg(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function M(t){return Array.isArray(t)?t.map(M):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[bg(o)]:M(t[o])}),{}):t}function Wr(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,[Wr(o)]:U(t[o])}),{}):t}var Cg={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},jo=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)||""}},zo=(0,oo.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?M(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),M(n))}),Gr=(0,oo.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}),$r=(0,oo.createAsyncThunk)("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),Cl=t=>t.info.agentInfo,wl=(0,oo.createSlice)({name:"info",initialState:Cg,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(zo.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(zo.rejected,e=>{e.fetchState="error"}).addCase(zo.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(Gr.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase($r.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(I,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:Tl}=wl.actions,El=wl.reducer;var ms={list:[],fetchState:"idle",isOpen:!1,page:"search"},kl=t=>t.search.isOpen,Rl=t=>t.search.page,Pl=t=>t.search.list;function Il(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var Ot=(0,fs.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:jo(n),tags:t.tags});return r.map(a=>({...a,source:`search-${a.type.toLowerCase()}`,searchTerm:t.query}))}),Al=(0,fs.createSlice)({name:"search",initialState:ms,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ms.fetchState,t.list=ms.list}},extraReducers:t=>{t.addCase(Ot.pending,e=>{e.fetchState="loading"}).addCase(Ot.rejected,(e,o)=>{e.fetchState="error",k.error(o.error)}).addCase(Ot.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(I,()=>ms)}}),{resetSearch:hs,setIsOpen:ae,setPage:X}=Al.actions,Ll=Al.reducer;var wg=/(https?:\/\/[^\s]+)/,ys=t=>t.split(" ").find(e=>wg.test(e));var Xr=T(require("classnames"));var Ss=require("react/jsx-runtime"),Tg=({onClick:t,shortKeys:e,children:o,...n})=>{let s=S("CommandPalette",te);return(0,Ss.jsxs)("button",{type:"button",...n,onClick:t,className:(0,Xr.default)(s.actionButton,n.className),children:[o,e&&e.map(r=>(0,Ss.jsx)("span",{className:(0,Xr.default)(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},no=Tg;var ze=require("react/jsx-runtime"),Eg=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=S("CommandPalette",te),a=E(Mt),{selected:l,setSelected:c}=dt(),p=r[l],d=p&&typeof p.text=="string"&&ys(p.text),u=(0,gt.useRef)(null);function m(y){if(!u.current)return;let _=u.current.querySelectorAll(".command-palette-list-item"),C=0,K=0;y==="down"?(_.forEach((Le,B)=>{B===l&&(C=B)}),K=C===_.length-1?0:C+1):y==="up"?(_.forEach((Le,B)=>{B===l&&(C=B)}),K=C?C-1:_.length-1):c(0);let H=_[K];H&&typeof K=="number"&&(c(K),H.scrollIntoView&&H.scrollIntoView({behavior:"smooth",block:K?"center":"end"}))}function f(){if(!u.current)return;let y=u.current.querySelectorAll(".command-palette-list-item"),_=0;y.forEach((K,H)=>{H===l&&(_=H)});let C=y[_];C&&C.click()}let g=()=>{d&&window.open(d,"_blank")},x=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},h=(0,gt.useCallback)(y=>{if(y.key==="Enter"&&y.altKey&&d){g();return}if(y.key==="Enter"&&y.shiftKey){w();return}if(y.key==="ArrowDown"){y.preventDefault(),y.stopPropagation(),m("down");return}if(y.key==="ArrowUp"){y.preventDefault(),y.stopPropagation(),m("up");return}y.key==="Enter"&&l!==-1&&(y.preventDefault(),y.stopPropagation(),f())},[l]);return(0,gt.useEffect)(()=>(window.addEventListener("keyup",h),()=>{window.removeEventListener("keyup",h)}),[h]),(0,ze.jsxs)("div",{className:i.actions,children:[(0,ze.jsx)("div",{className:i.actionsWrapper,ref:u,children:t}),(0,ze.jsxs)("div",{className:i.actionsBar,children:[d&&(0,ze.jsx)(no,{onClick:g,shortKeys:[gs()?8997:"ALT",8629],children:a("visitUrl")}),p&&(0,ze.jsxs)(gt.Fragment,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&(0,ze.jsx)(no,{onClick:w,shortKeys:[8679,8629],children:o}),(0,ze.jsx)(no,{onClick:x,shortKeys:[8629],children:e})]})]})]})},Ol=Eg;var Nl=require("react");var qo=require("react/jsx-runtime"),so=()=>(0,qo.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[(0,qo.jsx)("path",{d:"M0 0h24v24H0z",fill:"none"}),(0,qo.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 kg({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=S("CommandPalette",te);return(0,Te.jsxs)("div",{className:l.search,children:[(0,Te.jsx)("div",{className:l.searchIcon,children:(0,Te.jsx)(so,{})}),(0,Te.jsxs)("div",{className:l.searchInputWrapper,children:[(0,Te.jsx)("input",{ref:a,spellCheck:!1,autoComplete:"off",onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&(0,Te.jsx)("div",{className:l.selectWrapper,children:(0,Te.jsxs)("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&(0,Te.jsx)("option",{children:n}),s.map(c=>(0,Te.jsx)("option",{value:c.value,children:c.label},c.value))]})})]})]})}var Dl=(0,Nl.forwardRef)(kg);var Vo=require("react/jsx-runtime");function Nt({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[m,f]=(0,ro.useState)(0),g=(0,ro.useRef)(null),x=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var h;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(h=g.current)==null||h.focus();return}if(u.length>0){r("");return}a(!1)};return(0,ro.useEffect)(()=>{f(0)},[u,n]),(0,Vo.jsx)(Qt,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:x,children:(0,Vo.jsxs)(xl,{selected:m,setSelected:f,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&(0,Vo.jsx)(Dl,{ref:g,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}Nt.Page=Vr;Nt.List=jr;Nt.Image=yl;Nt.ListItem=qr;Nt.ActionsBar=Ol;Nt.Button=no;var A=Nt;var G=require("react/jsx-runtime"),Rg=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=S("EditSuggestionForm",Xa),l=(0,vs.useDispatch)(),c=E(Lr),p=(0,vs.useSelector)(f=>f.overlayInput.text);(0,Qr.useEffect)(()=>{t&&(l(Y.actions.reset()),l(Y.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(Y.actions.commitSuggestion()))},[t]);let d=f=>{f.preventDefault(),u(p)},u=f=>{l(ts(f)),e(f)},m=f=>g=>{p!==i?window.confirm(c("warning"))&&f(g):f(g)};return(0,Qr.useEffect)(()=>{n&&n(p!==i)},[n,t,p]),(0,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)(wr,{labels:t.searchKeywords}),(0,G.jsx)(fl,{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&&m(r),children:(0,G.jsx)(ss,{})}),(0,G.jsx)("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&m(s),children:(0,G.jsx)(Qa,{})})]}),(0,G.jsxs)("div",{className:a.primaryButtons,children:[(0,G.jsx)(A.Button,{onClick:m(o),shortKeys:["esc"],children:c("dismiss")}),(0,G.jsx)(A.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},_s=Rg;var Dt=require("@reduxjs/toolkit");var Pg=["{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}"],Ig=new RegExp(Pg.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function Hl(t,e){let o=t.split(Ig),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 Bl(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var Kl={suggestions:[],fetchState:"idle",isInitialRequest:null},Fl={default:Kl},Ul=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)||[]},zl=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},jl=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")},io=t=>t.textSuggestions,ql=t=>{let e=t.toLowerCase();return o=>{let n=o.text.toLowerCase();return n.startsWith(e)&&n.length>e.length}},xs=(0,Dt.createAction)("textSuggestions/refresh"),je=(0,Dt.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=$t(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,jo(n),t);if(t==="default"){let p=i?l.filter(ql(a)):l;e.dispatch(Oe(p.slice(0,r)))}return l}),Wo=(0,Dt.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,{...jo(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(ql(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?Hl(p.text,t):p.text}))),l=Bl(l,r),e.dispatch(Oe(l)),l}),Vl=(0,Dt.createSlice)({name:"textSuggestions",initialState:Fl,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(je.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||Kl;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(je.rejected,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="error")}).addCase(je.fulfilled,(e,o)=>{let n=o.meta.arg;e[n]&&(e[n].fetchState="done",e[n].suggestions=o.payload)}).addCase(Wo.pending,e=>{e.default.fetchState="loading"}).addCase(Wo.rejected,e=>{e.default.fetchState="error"}).addCase(Wo.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(I,()=>Fl)}}),{setTextSuggestions:Wl,setSuggestionState:Gl}=Vl.actions,$l=Vl.reducer;var Ql=require("@reduxjs/toolkit");var Xl={contentType:null,suggestion:null},Zl=t=>t.activeSuggestion.suggestion,Jl=t=>t.activeSuggestion.contentType,Yl=(0,Ql.createSlice)({name:"activeSuggestion",initialState:Xl,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(I,()=>Xl)}}),{setActiveSuggestion:qe,resetActiveSuggestion:Zr}=Yl.actions,ec=Yl.reducer;var Jr={};j(Jr,{enUS:()=>Ag,nlNL:()=>Lg});var Ag={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"}]},Lg={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 tc=require("@reduxjs/toolkit"),Mg={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var bs=({ui:t})=>t.overlayCollapsed;var oc=(0,tc.createSlice)({name:"ui",initialState:Mg,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:Go,setInputHasFocus:ao,setOverlayCollapsed:mt,setOpenOverlayWhenTyping:nc,setOverlayCollapsedUserOverwrite:sc}=oc.actions,rc=oc.reducer;var $o=T(require("react")),ac=require("react/jsx-runtime"),ic=$o.default.createContext(null),lo=({broadcastEvents:t,children:e})=>{let o=$o.default.useMemo(()=>t,[]);return(0,ac.jsx)(ic.Provider,{value:o,children:e})},he=()=>{let t=(0,$o.useContext)(ic);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};var co=require("@reduxjs/toolkit");var Og={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Ee=t=>t.auth.isLoggedIn,lc=t=>t.auth.loginFetchState,cc=t=>t.auth.verifyFetchState,pc=t=>t.auth.showLoginOverlay,ft=(0,co.createAsyncThunk)("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),dc=(0,co.createAsyncThunk)("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Xo=(0,co.createAsyncThunk)("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),uc=(0,co.createSlice)({name:"auth",initialState:Og,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(ft.pending,e=>{e.loginFetchState="loading"}),t.addCase(ft.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(ft.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Xo.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Xo.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Xo.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:po,setShowLoginOverlay:gc}=uc.actions,mc=uc.reducer;var Yr="SetActiveSuggestion",uo="ShowLoginOverlay",ei="UserLoggedIn",Ng="UserLoggedOut",Ve="ApplySuggestion",ti="ApplyImageSuggestion",Dg="ShowCommandPalette",Hg=t=>({[Yr]:e=>{t.dispatch(Gl(e.state)),t.dispatch(qe({contentType:e.contentType,suggestion:e.suggestion}))},[Dg]:e=>{t.dispatch(ae(e.isOpen)),e.page&&t.dispatch(X(e.page))},[uo]:e=>{t.dispatch(gc(e))},[ei]:()=>{t.dispatch(ft())},[Ng]:()=>{t.dispatch(ft())},[ti]:e=>{t.dispatch(ns({suggestion:e.suggestion}))},[Ve]:e=>{t.dispatch(we({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(ct())}}),fc=Hg;var oi=require("react/jsx-runtime"),Bg=()=>{var f;let[t,e]=(0,hc.useState)(!1),o=(0,go.useSelector)(Zl),n=(0,go.useSelector)(Jl),s=(0,go.useSelector)(io),r=(0,go.useDispatch)(),i=he(),a=E(Jr),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Zr()),r(ao(!0)),r(Y.actions.reset())},p=(g,x)=>{r(Zr()),r(ao(!0)),i.send(Ve,{text:g,suggestion:{...x,source:`${x.source||"text_recommendation"}-preview`}})};if(o===null||n===null)return null;let d=(f=s[n])==null?void 0:f.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(qe({contentType:n,suggestion:s[n].suggestions[d-1]})),m=d===s[n].suggestions.length-1||d===null?void 0:()=>r(qe({contentType:n,suggestion:s[n].suggestions[d+1]}));return(0,oi.jsx)(Qt,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:(0,oi.jsx)(_s,{onTouched:e,onDismiss:c,onUse:g=>p(g,o),suggestion:o,onNext:m,onPrevious:u})})},yc=Bg;var si=require("react-redux");var Cs=T(require("classnames")),ke=require("react"),ws=require("react-redux");var vc=T(require("classnames"));var Sc={root:"_root_1ukx5_1"};var _c=require("react/jsx-runtime"),Fg=({className:t,value:e,...o})=>{let n=S("TextInput",Sc);return(0,_c.jsx)("input",{className:(0,vc.default)(t,n.root),type:"text",value:e,...o})},Qo=Fg;var ni={};j(ni,{enUS:()=>Kg,nlNL:()=>Ug});var Kg={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"}]},Ug={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 xc={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 F=require("react/jsx-runtime");var zg=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},jg=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=E(ni),i=S("LoginTokenDialog",xc),a=(0,ws.useSelector)(cc),l=(0,ws.useDispatch)(),c=b("productName"),[p,d]=(0,ke.useState)(t||""),[u,m]=(0,ke.useState)(0),[f,g]=(0,ke.useState)(""),x=(0,ke.useCallback)(async _=>{_.preventDefault(),l(dc({email:p})),m(1)},[o,p]),w=()=>{g(""),m(0)},h=(0,ke.useCallback)(async _=>{_.preventDefault();let C=zg(_.target.elements.token.value);if(!C){g(r("verifyCodeError",{login:y}));return}l(Xo({token:C}))},[o]),y=(0,ke.useMemo)(()=>_=>(0,F.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:_},"back-button"),[]);return(0,ke.useEffect)(()=>{a==="error"&&g(r("verifyCodeError",{login:y})),a==="done"&&n()},[a]),(0,F.jsx)(Qt,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:(0,F.jsxs)("div",{className:i.root,children:[(0,F.jsx)("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&(0,F.jsxs)("form",{onSubmit:x,children:[(0,F.jsx)("h2",{className:i.subtitle,children:r("requestCodeTitle")}),(0,F.jsx)("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),(0,F.jsx)(Qo,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:_=>d(_.target.value)}),(0,F.jsx)("div",{className:i.actions,children:(0,F.jsx)("button",{type:"submit",className:(0,Cs.default)(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&(0,F.jsxs)("form",{onSubmit:h,children:[(0,F.jsx)("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),(0,F.jsx)("p",{className:i.text,children:r("verifyCodeBody")}),(0,F.jsx)(Qo,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),f&&(0,F.jsx)("div",{className:i.errorMessage,children:f}),(0,F.jsxs)("div",{className:i.actions,children:[(0,F.jsx)("button",{type:"button",className:(0,Cs.default)(i.button),onClick:w,children:r("back")}),(0,F.jsx)("button",{type:"submit",className:(0,Cs.default)(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},bc=jg;var wc=require("react/jsx-runtime"),qg=()=>{let t=(0,si.useSelector)(pc),e=(0,si.useSelector)(Cl),o=b("adminUrl"),n=he(),s=()=>n.send(uo,!1),r=()=>{n.send(uo,!1),n.send(ei)};return(0,wc.jsx)(bc,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},Cc=qg;var Gc=T(require("lodash.debounce")),ne=require("react"),$e=require("react-redux");var Ts=require("@reduxjs/toolkit");var Vg={data:null,fetchState:"idle"},Tc=t=>t.contentTypes.data,Zo=(0,Ts.createAsyncThunk)("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),Wg=(0,Ts.createSlice)({name:"contentTypes",initialState:Vg,reducers:{},extraReducers:t=>{t.addCase(Zo.pending,e=>{e.fetchState="loading"}).addCase(Zo.rejected,e=>{e.fetchState="error"}).addCase(Zo.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ec=Wg.reducer;function Jo(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 kc=require("react");function Rc(t,e){(0,kc.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 Yo=require("react"),Rs=require("react-redux");var Es=require("@reduxjs/toolkit");var Pc={data:null,fetchState:"idle"},ks=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},Re=(0,Es.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)}),Gg=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),$g=(0,Es.createSlice)({name:"entities",initialState:Pc,reducers:{},extraReducers:t=>{t.addCase(Re.pending,e=>{e.fetchState="loading"}).addCase(Re.rejected,e=>{e.fetchState="error"}).addCase(Re.fulfilled,(e,o)=>{e.fetchState="done",e.data=Gg(e.data?[...e.data,...o.payload]:o.payload)}).addCase(I,()=>Pc)}}),Ic=$g.reducer;var ri={};j(ri,{enUS:()=>Xg,nlNL:()=>Qg});var Xg={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Qg={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var Ac={root:"_root_17kae_1",empty:"_empty_17kae_5"};var Ht=require("react/jsx-runtime"),Zg=({onCopy:t,onUse:e})=>{let o=(0,Yo.useRef)(null),n=S("EntitiesList",Ac),s=E(ri),r=(0,Rs.useSelector)(ks),i=(0,Rs.useDispatch)();return(0,Yo.useEffect)(()=>{i(Re())},[]),(0,Yo.useEffect)(()=>{o.current&&o.current.focus()},[o]),(0,Ht.jsxs)("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&(0,Ht.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,Ht.jsx)(A.List,{children:r.map((a,l)=>(0,Ht.jsx)(A.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&(0,Ht.jsx)("p",{className:n.empty,children:s("noResults")})]})},Lc=Zg;var Pe=require("react"),en=require("react-redux");var Ps=require("@reduxjs/toolkit");var Mc={data:null,fetchState:"idle"},Oc=t=>t.summary.data,Nc=t=>t.summary.fetchState==="error",We=(0,Ps.createAsyncThunk)("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();return i.length===0?Promise.reject(new Error("No messages are included")):{summary:await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel})}}),Jg=(0,Ps.createSlice)({name:"summary",initialState:Mc,reducers:{},extraReducers:t=>{t.addCase(We.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(We.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(We.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(I,()=>Mc)}}),Dc=Jg.reducer;var ii={};j(ii,{enUS:()=>Yg,nlNL:()=>em});var Yg={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."}]},em={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 Hc={root:"_root_6ahh3_1",actions:"_actions_6ahh3_5",main:"_main_6ahh3_11",textInput:"_textInput_6ahh3_15",loading:"_loading_6ahh3_34",error:"_error_6ahh3_38"};var Ge=require("react/jsx-runtime"),tm=({onCopy:t})=>{let e=(0,Pe.useRef)(null),o=S("SummaryForm",Hc),[n,s]=(0,Pe.useState)(""),r=E(ii),i=(0,en.useSelector)(Oc),a=(0,en.useSelector)(Nc),l=(0,en.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(We())},[]),(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,Ge.jsx)("div",{className:o.root,tabIndex:-1,children:a?(0,Ge.jsx)("p",{className:o.error,children:r("error")}):(0,Ge.jsxs)(Pe.Fragment,{children:[(0,Ge.jsx)("div",{className:o.main,children:(0,Ge.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,Ge.jsx)("div",{className:o.actions,children:(0,Ge.jsx)(A.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},Bc=tm;var ai={};j(ai,{enUS:()=>om,nlNL:()=>nm});var om={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},nm={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Gesprek samenvatten"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeAssist:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var ht=T(require("react")),on=require("react-redux");var li={};j(li,{enUS:()=>sm,nlNL:()=>rm});var sm={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"}]},rm={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 Fc={root:"_root_1g4pq_1",title:"_title_1g4pq_9",empty:"_empty_1g4pq_20",status:"_status_1g4pq_24",form:"_form_1g4pq_30",input:"_input_1g4pq_43",submit:"_submit_1g4pq_55",question:"_question_1g4pq_63",answer:"_answer_1g4pq_67",alignRight:"_alignRight_1g4pq_73"};var fo=require("@reduxjs/toolkit");var ci={data:[],fetchState:"idle"},Kc=t=>{var e;return(e=t.answer)==null?void 0:e.data},Uc=t=>t.answer.fetchState,ho=(0,fo.createAction)("answer/resetKnowledgeSearch"),mo=(0,fo.createAsyncThunk)("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeAssist({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),im=(0,fo.createSlice)({name:"answer",initialState:ci,reducers:{},extraReducers:t=>{t.addCase(mo.pending,e=>{e.fetchState="loading"}).addCase(mo.rejected,e=>{e.fetchState="error"}).addCase(mo.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(I,()=>ci).addCase(ho,()=>ci)}}),zc=im.reducer;var tn=require("react/jsx-runtime"),jc=()=>(0,tn.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[(0,tn.jsx)("title",{id:"paperPlaneTitle",children:"PaperPlane"}),(0,tn.jsx)("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});var oe=require("react/jsx-runtime"),am=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=ht.default.useState(""),{setSelected:i}=dt(),a=(0,ht.useRef)(null),l=S("EntitiesList",Fc),c=E(li),p=(0,on.useDispatch)(),d=(0,on.useSelector)(Kc),u=(0,on.useSelector)(Uc),m=async g=>{g.preventDefault(),g.stopPropagation(),s!==""&&p(mo({question:s,promptInstruction:n}))},f=(g,x)=>{p(ie({name:"knowledge assist source viewed",data:{question:x,sourceViewed:g.url||g.name},options:{includeConversationData:!0}}))};return(0,ht.useEffect)(()=>{var g;o&&u==="idle"?p(mo({question:o,promptInstruction:n})):(g=a.current)==null||g.focus()},[a,u]),(0,ht.useEffect)(()=>{u==="done"&&(p(ie({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,answer:d[d.length-1].answer.answer,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(d.length-1),r(""))},[u,d]),(0,ht.useEffect)(()=>{a.current&&a.current.scrollIntoView({behavior:"smooth"})},[a,d]),(0,oe.jsxs)("div",{className:l.root,children:[d.length>0&&(0,oe.jsx)("div",{className:l.alignRight,children:(0,oe.jsx)(A.Button,{onClick:e,children:c("reset")})}),(0,oe.jsxs)(A.ActionsBar,{list:d.map(({answer:g})=>({text:g.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:g=>t(g.text),children:[d.map(({question:g,answer:x},w)=>(0,oe.jsx)(A.List,{children:(0,oe.jsx)(A.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:x.answer,closeOnSelect:!0,onClick:()=>t(x.answer),onSourceClick:h=>f(h,g),sources:x.sources,styles:{title:l.question,description:l.answer},children:g})},`${x.answer}_${w}`)),u==="loading"&&(0,oe.jsx)("p",{className:l.status,children:c("loading")}),u==="error"&&(0,oe.jsx)("p",{className:l.status,children:c("error")}),(0,oe.jsxs)("form",{className:l.form,onSubmit:m,children:[(0,oe.jsx)("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:g=>{i(-1),r(g.target.value)}}),(0,oe.jsx)("button",{type:"submit",className:l.submit,children:(0,oe.jsx)(jc,{})})]})]})]})},qc=am;var Is=require("@reduxjs/toolkit");var lm={data:null,fetchState:"idle"},yo=t=>t.profile.data,As=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],nn=(0,Is.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)}),cm=(0,Is.createSlice)({name:"profile",initialState:lm,reducers:{},extraReducers:t=>{t.addCase(nn.pending,e=>{e.fetchState="loading"}).addCase(nn.rejected,e=>{e.fetchState="error"}).addCase(nn.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Vc=cm.reducer;var z=require("react/jsx-runtime"),pm=200,dm=5,um=4,gm=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Wc=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),mm=()=>{let t=(0,$e.useDispatch)(),e=he(),o=E(ai),[n,s]=(0,ne.useState)(!1),[r,i]=(0,ne.useState)(""),a=(0,$e.useSelector)(Rl),l=(0,$e.useSelector)(yo),[c,p]=(0,ne.useState)(null),[d,u]=(0,ne.useState)([]),[m,f]=(0,ne.useState)(),g=(0,$e.useSelector)(Ee),x=b("showSearch"),w=b("showEntitiesCommand"),h=b("showSummaryCommand"),y=b("showKnowledgeSearch"),_=b("showImageSearch"),C=b("searchTriggerKey"),K=(0,$e.useSelector)(Tc),H=(0,$e.useSelector)(Pl),Le=(0,$e.useSelector)(kl),B=v=>dr(H.filter(L=>L.type===v.toUpperCase()),v),P=[{value:"PERSONAL",label:o("personalSuggestions"),list:B("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:B("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:B("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:B("IMAGE"),listOrientation:"horizontal",shouldShow:_}].filter(v=>v.shouldShow),J=[{label:o("entitiesClipboard"),onClick:()=>t(X("entities")),shouldShow:w&&Wc(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(X("summary")),shouldShow:h&&Wc(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeAssist")}: ${r}`:o("knowledgeAssist"),onClick:()=>t(X("knowledgeAssist")),shouldShow:y,experimental:!0}].filter(v=>v.shouldShow),ve=(K==null?void 0:K.map(v=>({value:v.code.toUpperCase(),label:`${v.name}s`,list:B(v.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],cr=(0,ne.useCallback)((0,Gc.default)((v,L)=>{t(Ot({query:v,type:L,tags:["search-overlay"]}))},pm),[]),wt=gm([...ve,...P]),au=(0,ne.useCallback)((v,L)=>{if(!L)return;let st=[...P,...ve].find(({value:zt})=>zt===L);st&&(t(X("edit")),p({...v,searchTerm:void 0}),u(st.list))},[t,c,ve]),pr=(0,ne.useCallback)((v,L)=>{switch(L.type){case"IMAGE":e.send(ti,{suggestion:L});break;default:e.send(Ve,{text:v,suggestion:L})}t(ae(!1))},[t]),lu=v=>{Jo(v.text),t(ie({name:"entity copied",data:{entity:v,type:"copy"}})),t(ae(!1))},cu=v=>{e.send(Ve,{text:v,suggestion:{source:"knowledge-assist",text:v}}),t(ie({name:"answer used",data:{originalText:v},options:{includeConversationData:!0}})),i(""),t(X("search")),t(ho()),t(ae(!1))},pu=v=>{Jo(v),t(ae(!1))},du=v=>{e.send(Ve,{text:v.text,suggestion:{source:"entity",text:v.text}}),t(ae(!1))},uu=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),gu=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function dr(v,L){return v.slice(0,m?10:L.toLowerCase()==="image"?um:dm)}function Vi(v,L,st){return L.reduce((zt,vn)=>st&&m===st?vn.length+zt:dr(vn,st).length+zt,v)}function Ut(v){return L=>{n?window.confirm(o("warning"))&&(v(L),s(!1)):v(L)}}return(0,ne.useEffect)(()=>{r?cr(r,m):t(hs())},[r,m]),(0,ne.useEffect)(()=>{a==="search"&&t(ho())},[a]),(0,ne.useEffect)(()=>{g&&t(Zo())},[g]),Rc(C,()=>t(ae(!0))),!x||!l?null:(0,z.jsxs)(A,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ut(v=>t(ae(v))),onChangeType:v=>f(v),onChangePage:Ut(v=>t(X(v))),selectedType:m,search:r,page:a,isOpen:Le,types:[...ve,...P],children:[(0,z.jsx)(A.Page,{id:"search",children:(0,z.jsxs)(A.ActionsBar,{list:[...J.map(v=>({text:v.label,type:"command"})),...wt.map(v=>({text:v.text||v.url||v.message,type:v.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:v},L)=>pr(v,wt[L]),onSecondary:(v,L)=>{au(wt[L-J.length],wt[L-J.length].type)},children:[J.length>0&&(0,z.jsx)(A.List,{heading:o("commands"),children:J.map((v,L)=>(0,z.jsx)(A.ListItem,{index:Vi(L,[],"commands"),closeOnSelect:!1,onClick:v.onClick,isExperimental:v.experimental,children:v.label},v.label))}),[...ve,...P].map(({value:v,label:L,list:st,lineClamp:zt,listOrientation:vn},mu)=>(0,z.jsx)(A.List,{heading:L,orientation:vn==="horizontal"?"horizontal":"vertical",children:dr(st,v).map((_e,fu)=>(0,z.jsx)(A.ListItem,{index:Vi(J.length+fu,[...ve,...P].slice(0,mu).map(({list:hu})=>hu),v),closeOnSelect:!1,lineClamp:zt,onClick:()=>pr(_e.text,_e),description:v!=="IMAGE"?_e.title&&_e.text:void 0,children:v==="IMAGE"?(0,z.jsx)(A.Image,{title:_e.title||_e.text,src:_e.image}):_e.title||_e.text},`${_e.id}-${_e.text}`))},v))]})}),(0,z.jsx)(A.Page,{id:"edit",onDismiss:Ut(()=>{t(X("search")),p(null)}),children:c&&(0,z.jsx)(_s,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(X("search")),p(null),u([])},onNext:gu,onPrevious:uu,onUse:v=>{t(X("search")),pr(v,{...c,source:`${c.source||"text_recommendation"}-preview`}),t(ae(!1)),u([]),p(null)}})}),(0,z.jsx)(A.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Ut(()=>{t(X("search"))}),children:(0,z.jsx)(Lc,{onUse:du,onCopy:lu})}),(0,z.jsx)(A.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Ut(()=>{t(X("search"))}),children:(0,z.jsx)(Bc,{onCopy:pu})}),(0,z.jsx)(A.Page,{id:"knowledgeAssist",title:o("knowledgeAssist"),isExperimental:!0,onDismiss:Ut(()=>{t(ho()),t(X("search"))}),children:(0,z.jsx)(qc,{promptInstruction:l.knowledgeAssistPromptInstruction,question:r,onUse:cu,onResetQuestion:()=>{t(ho()),i("")}})})]})},$c=mm;var So=require("react/jsx-runtime"),fm=()=>{let t=b("showSearch"),e=b("isEmbedded");return(0,So.jsxs)(Xc.Fragment,{children:[t&&(0,So.jsx)($c,{}),(0,So.jsx)(yc,{}),e&&(0,So.jsx)(Cc,{})]})},Qc=fm;var Xe=require("react-redux");function vo(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 Ms=require("react");var op=require("interweave"),xo=require("react"),Ls=require("react-redux");var Zc=require("react");function Jc(t,e,o){(0,Zc.useEffect)(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var hm=/[.*+?^${}()|[\]\\]/g,ym=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function Sm(t){return t.replace(hm,"\\$&")}function vm(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function _m(t){return t.search(ym)}function Yc(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${Sm(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function ep(t){return t.replace(Wt,'<mark data-type="placeholder">$1</mark>')}function _o(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function xm(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 pi(t,e,o={}){if(e){let n=vm(e.toLowerCase(),t.toLowerCase()),s=_o(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=_m(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(Ca).length>3||e.length>30?xm(e.trim(),n):0;return`${`${i>0?"\u2026":""}${_o(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var tp={badge:"_badge_1syy2_1",formattedText:"_formattedText_1syy2_5"};var di=require("react/jsx-runtime"),Cm=["search","personal-collection-search","search-autocomplete"];function wm(t,e,o,n={}){let s="";return Cm.includes(e)?s=Yc(pi(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=pi(t,o,n),n.placeholders===!0&&(s=ep(s)),s}var Tm=()=>{},Em=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=(0,Ls.useSelector)($t),r=(0,Ls.useDispatch)(),i=S("TextSuggestion",tp),a=(0,xo.useRef)(null);(0,xo.useEffect)(()=>{let c=setTimeout(()=>{r(Ua({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),Jc(a,"click",()=>{r(It(t)),r(we({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=(0,xo.useMemo)(()=>wm(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"&&!n?null:(0,di.jsx)(O,{ref:a,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:Tm,children:(0,di.jsx)(op.Interweave,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},np=Em;var ui=require("react/jsx-runtime"),km=({suggestions:t,selectedIndex:e,reverse:o})=>{let n=(0,Ms.useMemo)(()=>{let s=t.map((r,i)=>(0,ui.jsx)(np,{index:i,selected:i===e,suggestion:r},`${r.text}-${r.source}`));return o?s.reverse():s},[t,e,o]);return(0,ui.jsx)(Ms.Fragment,{children:n})},Os=km;var sp={root:"_root_otdbu_1",paper:"_paper_otdbu_11"};var sn=require("react/jsx-runtime"),Rm=({textSuggestions:t,selectedIndex:e})=>{let o=S("InlineSuggestionsOverlay",sp),n=(0,Xe.useSelector)(vo),s=(0,Xe.useDispatch)(),r=(0,Xe.useSelector)(Ee),i=(0,Xe.useSelector)(Gt),a=(0,Xe.useSelector)(bs),l=b("showTextSuggestions");return eo(()=>{s(mt({collapse:!0,skipWhenInputFocus:!0}))}),a||!n||!l||t.length===0||r!==!0||i===!1?null:(0,sn.jsx)("div",{className:o.root,"data-variant":"inline",children:(0,sn.jsx)("div",{className:o.paper,children:(0,sn.jsx)(ge,{children:(0,sn.jsx)(Os,{suggestions:t,selectedIndex:e})})})})},Pm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),rp=(0,Xe.connect)(Pm)(Rm);var Ds=T(require("classnames")),bo=require("react"),Ze=require("react-redux");var ip=require("react");function ap(t,e){let[o,n]=(0,ip.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)}}]}var cp=T(require("classnames")),Qe=require("react");var gi={};j(gi,{enUS:()=>Im,nlNL:()=>Am});var Im={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"}]}]},Am={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 lp={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};var yt=require("react/jsx-runtime"),mi=(t,e,o)=>n=>(0,yt.jsx)("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Lm=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=E(gi),r=he(),i=S("Login",lp),a=b("productName"),l=(0,Qe.useCallback)(g=>{g.preventDefault(),n&&n(parseInt(g.target.value,10))},[]),c=(0,Qe.useCallback)(g=>{g.preventDefault(),r.send(uo,!0)},[e]),p=(0,Qe.useMemo)(()=>g=>(0,yt.jsx)("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[e]),d=(0,Qe.useCallback)(g=>(0,yt.jsx)("button",{type:"button",className:i.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:u,hour:m,day:f}=(0,Qe.useMemo)(()=>({min:mi(i,60*10,l),hour:mi(i,60*60,l),day:mi(i,60*60*12,l)}),[]);return(0,yt.jsxs)("div",{className:(0,cp.default)(t,i.root),children:[s("loginPlease",{login:o?d:p,productName:a}),n&&(0,yt.jsxs)(Qe.Fragment,{children:[(0,yt.jsx)("br",{}),s("snooze",{min:u,hour:m,day:f})]})]})},Ns=Lm;var dp=require("react-redux");var pp={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};var rn=require("react/jsx-runtime"),Mm=({title:t})=>{let e=S("SearchTrigger",pp),o=(0,dp.useDispatch)();return(0,rn.jsxs)("button",{type:"button",className:e.root,onClick:()=>o(ae(!0)),children:[(0,rn.jsx)(so,{}),(0,rn.jsx)("span",{className:e.text,children:t})]})},up=Mm;var fi={};j(fi,{enUS:()=>Om,nlNL:()=>Nm});var Om={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"}]},Nm={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 gp={root:"_root_onpov_1",isInline:"_isInline_onpov_14",toggleButton:"_toggleButton_onpov_21",toggleButtonWrapper:"_toggleButtonWrapper_onpov_25",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_onpov_32",isCollapsed:"_isCollapsed_onpov_36",collapsible:"_collapsible_onpov_36",hints:"_hints_onpov_44",hintsHidden:"_hintsHidden_onpov_51",triggers:"_triggers_onpov_56",triggersRight:"_triggersRight_onpov_71"};var N=require("react/jsx-runtime"),Dm=({textSuggestions:t,selectedIndex:e})=>{let o=S("SuggestionsOverlay",gp),n=E(fi),s=(0,Ze.useSelector)(vo),r=Da(),i=(0,Ze.useDispatch)(),a=(0,bo.useRef)(null),l=b("searchTriggerKey"),c=b("productName"),p=(0,Ze.useSelector)(bs),d=(0,Ze.useSelector)(Ee),u=(0,Ze.useSelector)(Gt),[m,f]=(0,bo.useState)(null),g=b("showSearch"),x=b("showTextSuggestions"),w=b("adminUrl"),h=b("isEmbedded"),[y,_]=ap("dd-snooze-until-ms",0),C=p||y>Date.now(),K=t.filter(B=>B.source!=="gpt").length,H=()=>{C&&_(0),i(sc(!C))},Le=B=>{let P=Date.now()+B*1e3;_(P),k.info(`Snooze until: ${new Date(P)}`),i(mt({collapse:!0}))};return(0,bo.useEffect)(()=>{K===0&&f(null)},[t,K]),eo(()=>{i(mt({collapse:!0,skipWhenInputFocus:!0}))}),d===null||u===!1?null:d===!1?(0,N.jsxs)("div",{ref:a,className:(0,Ds.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1}}),(0,N.jsx)("div",{className:o.triggersRight,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("collapse"),onClick:H,isCollapsed:!1})})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("open",{productName:c}),onClick:H,isCollapsed:!0})}),(0,N.jsx)("div",{className:o.collapsible,children:(0,N.jsx)(Ns,{loginUrl:w,isEmbedded:h,onSnooze:Le})})]}):!r||!s?null:(0,N.jsxs)("div",{ref:a,className:(0,Ds.default)(o.root,{[o.isCollapsed]:C}),children:[!C&&(0,N.jsxs)("div",{className:o.triggers,children:[(0,N.jsx)("div",{style:{flex:1},children:g&&(0,N.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>f(n(gs()?"searchHintMac":"searchHintWindows",{searchTriggerKey:l.toUpperCase()})),onMouseLeave:()=>f(null),children:(0,N.jsx)(up,{title:n("search")})})}),(0,N.jsxs)("div",{className:o.triggersRight,onFocus:()=>{},children:[(0,N.jsx)("div",{className:(0,Ds.default)(!m&&o.hintsHidden,o.hints),children:m}),(0,N.jsx)(Rt,{className:o.toggleButton,title:n("collapse"),onClick:H,isCollapsed:!1})]})]}),(0,N.jsx)("div",{className:o.toggleButtonWrapper,children:(0,N.jsx)(Rt,{className:o.toggleButton,title:n("open",{productName:c}),onClick:H,isCollapsed:!0})}),K>0&&x&&(0,N.jsx)("div",{className:o.collapsible,onFocus:()=>{},children:(0,N.jsx)(ge,{children:(0,N.jsx)(Os,{suggestions:t,selectedIndex:e,reverse:!0})})})]})},Hm=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),mp=(0,Ze.connect)(Hm)(Dm);var fp=require("react-redux");var an=require("react/jsx-runtime"),Bm=({children:t})=>{let o=b("locale").replace("-","");return(0,an.jsx)(_r.Provider,{value:o,children:t})},Fm=({store:t,customStyles:e={},children:o})=>(0,an.jsx)(fp.Provider,{store:t,children:(0,an.jsx)(Bm,{children:(0,an.jsx)(Ro.Provider,{value:e,children:o})})}),Co=Fm;var Xs=T(require("classnames")),Op=require("interweave"),et=require("react"),Np=require("react-redux");var hp=require("react"),Km=["div","span","mark","strong","b","i","u","em"];function hi(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(Km.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),(0,hp.cloneElement)(n,{children:hi(i,e,o+1)})]}return[...t,...e]}function St(t){return t.tagName.toLowerCase()==="textarea"}var yp={root:"_root_81non_1",container:"_container_81non_3",agentText:"_agentText_81non_5",tabText:"_tabText_81non_6",hint:"_hint_81non_6",matchSelection:"_matchSelection_81non_10",focus:"_focus_81non_16",resetIndent:"_resetIndent_81non_20",matchKeyword:"_matchKeyword_81non_24",matchPlaceholder:"_matchPlaceholder_81non_25",hover:"_hover_81non_31",hintText:"_hintText_81non_64",popover:"_popover_81non_72",popoverRoot:"_popoverRoot_81non_77",popoverContentContainer:"_popoverContentContainer_81non_81",popoverContent:"_popoverContent_81non_81",selectionOptions:"_selectionOptions_81non_107",selectionOptionsIsHidden:"_selectionOptionsIsHidden_81non_112",selectionOptionsButton:"_selectionOptionsButton_81non_116",caret:"_caret_81non_132",popoverSuggestionsRoot:"_popoverSuggestionsRoot_81non_136",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_81non_141"};var Ep=T(require("classnames")),kp=require("interweave"),Vs=require("react");function Sp(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Hs(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function vp(t){return t!=null}var Si=T(require("classnames")),ye=require("react");var Bs=require("react"),Um=["bottom","height","left","right","top","width"],zm=(t={},e={})=>Um.some(o=>t[o]!==e[o]),Je=new Map,_p,xp=()=>{let t=[],e=[];Je.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();zm(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Je.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),_p=window.requestAnimationFrame(xp)};function jm(t,e){return{observe(){let o=Je.size===0;if(Je.has(t)){let n=Je.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Je.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&xp()},unobserve(){let o=Je.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Je.delete(t),Je.size||cancelAnimationFrame(_p)}}}}function yi(t){let[e,o]=(0,Bs.useState)(null);return(0,Bs.useLayoutEffect)(()=>{if(!t.current)return;let n=jm(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}var wo=require("react"),Cp=require("react-dom");var bp={root:"_root_1jq08_1"};var wp=({children:t})=>{let[e,o]=(0,wo.useState)(null),n=(0,wo.useContext)(Ro);return(0,wo.useLayoutEffect)(()=>{let s=document.createElement("div");return At(s),s.classList.add(bp.root),n!=null&&n.portalRootNode&&s.classList.add(n==null?void 0:n.portalRootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?(0,Cp.createPortal)(t,e):null};var He={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 Fs=require("react/jsx-runtime"),Ks=(t=!1)=>{let[e,o]=(0,ye.useState)(t),n=(0,ye.useCallback)(()=>o(!0),[]),s=(0,ye.useCallback)(()=>o(!1),[]),r=(0,ye.useCallback)(()=>o(a=>!a),[]),i=(0,ye.useRef)(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function vi(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 Us=({className:t,triggerRef:e,boundaryRef:o=(0,ye.createRef)(),position:n="above",align:s="center",children:r,toStyle:i=vi,...a})=>{let l=yi(e),c=yi(o),p=(0,ye.useMemo)(()=>i(l,c,0),[l,c]);return(0,Fs.jsx)(wp,{children:(0,Fs.jsx)("div",{className:(0,Si.default)(He.ref,{[He.positionAbove]:n==="above",[He.positionBelow]:n==="below",[He.positionLeft]:n==="left",[He.positionRight]:n==="right",[He.alignStart]:s==="start",[He.alignCenter]:s==="center",[He.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:(0,Fs.jsx)("div",{className:(0,Si.default)(t,He.root),children:r})})})};var Tp=T(require("classnames")),zs=require("react");var _i=require("react/jsx-runtime"),js=(0,zs.forwardRef)(({className:t,children:e,...o},n)=>{let s=(0,zs.useRef)(null),r=S("TabCompletion",Fe);return(0,_i.jsx)("div",{ref:Hs([s,n]),className:(0,Tp.default)(t,r.popoverContentContainer),...o,children:(0,_i.jsx)("div",{className:r.popoverContent,children:e})})});var vt=require("react/jsx-runtime"),qm=t=>e=>{let o=vi(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},Vm=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=S("TabCompletion",Fe),i=Ks(),a=(0,Vs.useMemo)(()=>qm(t.getBoundingClientRect()),[t]),[l,c]=rs(t);return(0,Vs.useEffect)(()=>{c?i.open():i.close()},[c]),(0,vt.jsxs)("span",{children:[(0,vt.jsx)("mark",{ref:Hs([l,i.triggerRef]),className:(0,Ep.default)(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&(0,vt.jsx)(Us,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:(0,vt.jsx)(js,{style:o,children:(0,vt.jsx)("div",{className:r.hintText,children:s})})})]})},qs=class extends kp.Matcher{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${Sp(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(vp);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return(0,vt.jsx)(Vm,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};var Gs=T(require("classnames")),Lp=require("interweave"),Z=require("react"),Mp=require("react-redux");var xi=require("react/jsx-runtime"),Rp=()=>(0,xi.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,xi.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 _t=require("react"),ln=require("react-redux"),Ip=T(require("lodash.debounce"));var Pp={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Ws(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 bi(t){return t.replace("https://www.","").replace("https://","")}var Se=require("react/jsx-runtime"),Wm=3,Gm=t=>({image:t.image||"",text:t.text,id:t.id,title:t.title}),$m=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=Wm})=>{let r=S("LinkSearch",Pp),[i,a]=(0,_t.useState)(""),l=(0,ln.useDispatch)(),c=(0,ln.useSelector)(Ul("url")),p=(0,ln.useSelector)(Il("URL",Gm)),[d,u]=(0,_t.useState)(p.length-1),m=b("fallbackImage"),f=h=>{let y=h.target;a(y.value)},g=(h,y)=>{h.stopPropagation(),h.preventDefault(),window.open(y,"_blank")},x=h=>{var C;let y=d-1<0?p.length-1:d-1,_=d+1===p.length?0:d+1;h.code==="Escape"&&(a(""),e()),h.code==="ArrowUp"&&u(y),h.code==="ArrowDown"&&u(_),h.code==="Enter"&&t(((C=p[d])==null?void 0:C.text)||i)},w=(0,_t.useCallback)((0,Ip.default)(h=>{l(Ot({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,_t.useEffect)(()=>{i&&w(i)},[i]),(0,_t.useEffect)(()=>()=>{l(hs())},[]),(0,Se.jsxs)("div",{className:r.root,children:[(0,Se.jsx)(ge,{withDivider:!0,children:(i?p:c).slice(0,s).map((h,y)=>(0,Se.jsx)(O,{selected:d===y,onClick:()=>t(h.text),"data-testid":"linksearch-suggestion",children:(0,Se.jsxs)(D,{children:[(0,Se.jsx)(D.Image,{src:Ws(h,"small",m||void 0),title:h.title||h.text}),(0,Se.jsxs)(D.Content,{className:r.content,cropText:!0,children:[(0,Se.jsx)(D.Title,{children:h.title||bi(h.text)}),h.title&&bi(h.text)]}),(0,Se.jsx)(O.Actions,{children:(0,Se.jsx)(O.ActionButton,{label:n,onClick:_=>g(_,h.text)})})]})},h.text))}),(0,Se.jsx)(Qo,{value:i,onChange:f,autoFocus:!0,placeholder:o,onKeyUp:x})]})},Ap=$m;var Ci={};j(Ci,{enUS:()=>Xm,nlNL:()=>Qm});var Xm={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},Qm={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var Q=require("react/jsx-runtime"),Zm=(0,Z.forwardRef)((t,e)=>{let o=S("TabCompletion",Fe);return(0,Q.jsx)("mark",{ref:e,className:(0,Gs.default)(o.matchSelection)},"selection-start")}),Jm=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=E(Ci),i=S("TabCompletion",Fe),a=(0,Z.useRef)(null),l=(0,Z.useRef)(null),[c,p]=(0,Z.useState)(null),d=(0,Mp.useDispatch)(),u=Ks(document.activeElement===n),[m]=(0,Z.useState)(()=>document.createRange());u.triggerRef.current=m,(0,Z.useEffect)(()=>()=>m.detach(),[]),(0,Z.useEffect)(()=>{let g=t.current,x=a.current;!g||!x||(m.setStart(g,0),m.setEnd(x,0))},[t.current,a.current]),eo(()=>{u.close()});let f=(0,Z.useCallback)(g=>{let x=m.toString(),w=/^http(s?):\/\//.test(g)?g:`https://${g}`;d(Yn({text:`[${x}](${w})`,replace:"selection"}))},[]);return(0,Q.jsxs)("span",{children:[(0,Q.jsx)("mark",{ref:a,className:(0,Gs.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&(0,Q.jsx)(Us,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:(0,Q.jsxs)(js,{style:o,ref:l,children:[(0,Q.jsx)("div",{className:(0,Gs.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:(0,Q.jsxs)("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[(0,Q.jsx)(Rp,{}),(0,Q.jsx)("span",{children:"\xA0"}),(0,Q.jsx)("span",{children:r("insertLink")})]})}),c==="insertLink"&&(0,Q.jsx)(Ap,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:f,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},$s=class extends Lp.Matcher{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=(0,Z.createRef)(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?(0,Q.jsx)(Zm,{ref:this.startRef}):(0,Q.jsx)(Jm,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};var Ye=require("react/jsx-runtime"),Ym=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=S("TabCompletion",yp),p=b("insertLink"),d=b("showMidSentenceSuggestions"),u=b("inlineSuggestions"),m=as(a),f=(0,et.useRef)(null);(0,et.useEffect)(()=>{St(a)&&m&&ls(a,m)},[m]);let g=(0,et.useCallback)(h=>{if(!s||!o)return h;let y=[(0,Ye.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Ye.jsx)("span",{"data-testid":"tab-completion",className:(0,Xs.default)(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&y.push((0,Ye.jsx)("span",{className:(0,Xs.default)(c.hint,c.resetIndent),children:(0,Ye.jsx)(Un,{keyCode:"tab"},"tabHint")})),hi(h,y)},[s,o,n]),x=(0,et.useMemo)(()=>{let h=[];return p&&h.push(new $s("selection")),h.push(new Jt("placeholders")),r&&h.push(new qs("keywords")),h},[u,p,r]),w=(0,et.useMemo)(()=>{let h=window.getComputedStyle(a);return{"--dd-color":h.color,"--dd-font-size":h.fontSize,"--dd-font-family":h.fontFamily,"--dd-font-variant":h.fontVariant}},[]);return t?(0,Ye.jsxs)("div",{ref:h=>{h!=null&&h.parentElement&&(f.current=h==null?void 0:h.parentElement)},className:c.root,style:w,children:[(0,Ye.jsx)(Op.Interweave,{tagName:"span",containerTagName:"div",className:(0,Xs.default)(c.container,c.agentText),disableLineBreaks:St(a),content:e||"\u200B",onAfterParse:g,matchers:x,selection:m,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:f,inlineSuggestionsOnlyAtEnd:!d}),(0,Ye.jsx)("br",{})]}):null},ef=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var g;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??_o(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:m,showStyleSuggestions:f}=o;return{showTabHint:p,showStyleSuggestions:f,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((g=n.list)==null?void 0:g.keywordMatches)??[],enabled:m&&d!==!1}},Dp=(0,Np.connect)(ef)(Ym);var kd=T(require("classnames")),Rd=require("react"),V=require("react-redux");var xt=require("@reduxjs/toolkit");var Hp={list:[],fetchState:"idle",isInitialRequest:null},Fp=t=>t.autoflows.list||[],Bp=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},tt=(0,xt.createAsyncThunk)("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),wi=(0,xt.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(tt(t.platformSessionId))}),Ti=(0,xt.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(tt(t.platformSessionId))}),tf=(0,xt.createSlice)({name:"autoflows",initialState:Hp,reducers:{},extraReducers:t=>{t.addCase(wi.pending,(e,o)=>{let n=Bp(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(Ti.pending,(e,o)=>{let n=Bp(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(tt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(tt.rejected,e=>{e.fetchState="error"}),t.addCase(tt.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(I,()=>Hp)}}),Kp=(0,xt.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(tt(t))}),s.on("sessionCompleted",()=>{o(tt(t))})}),Up=(0,xt.createAsyncThunk)("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),zp=tf.reducer;var bt=require("@reduxjs/toolkit");var jp={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},qp=t=>t.customMessages.list,Vp=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Wp=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Gp=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),cn=(0,bt.createAsyncThunk)("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Qs=(0,bt.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)}),Zs=(0,bt.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)}),$p=(0,bt.createSlice)({name:"customMessages",initialState:jp,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(cn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Qs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Qs.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Zs.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Zs.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(I,()=>jp)}}),Xp=(0,bt.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($p.actions.onCustomMessage(r))})}),Qp=(0,bt.createAsyncThunk)("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Zp=$p.reducer;var pn=require("@reduxjs/toolkit"),of={jwt:null,accountUrl:null,interval:null},Jp=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},Ei=(0,pn.createAsyncThunk)("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),ki=(0,pn.createAsyncThunk)("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(Ei()),setInterval(()=>n(Ei()),o)}),Yp=(0,pn.createSlice)({name:"exchangeToken",initialState:of,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(Ei.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(ki.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:ed}=Yp.actions,td=Yp.reducer;function od(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}var dd=require("react"),ud=require("react-redux");var ld=T(require("classnames")),cd=require("react");var sd=T(require("classnames"));var nd={root:"_root_838fd_1"};var id=require("react/jsx-runtime"),nf=({className:t,children:e})=>{let o=S("Unicode",nd);return(0,id.jsx)("span",{className:(0,sd.default)(t,o.root),children:e})},rd=nf;var ad={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 Ri={};j(Ri,{enUS:()=>sf,nlNL:()=>rf});var sf={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"}]},rf={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"),lf=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=S("Autoflow",ad),a=E(Ri),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,le.jsxs)(O,{className:(0,ld.default)(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[(0,le.jsx)(D,{children:(0,le.jsxs)(D.Content,{children:[(0,le.jsxs)(D.Title,{children:[e&&(0,le.jsx)("span",{className:i.stateBadge,children:a(e)}),o]}),(0,le.jsx)("span",{children:n})]})}),(0,le.jsx)(O.Actions,{fixed:e==="Started",children:(0,le.jsx)(O.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:(0,le.jsxs)(cd.Fragment,{children:[(0,le.jsx)(rd,{children:c})," ",(0,le.jsx)("span",{children:a(l)})]})})})]})},pd=lf;var Pi=require("react/jsx-runtime"),cf=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},pf=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>(0,Pi.jsx)(dd.Fragment,{children:t.map(s=>(0,Pi.jsx)(pd,{displayName:s.displayName,description:s.description,disabled:s.isBusy||cf(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),df=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},uf={onStartAutoflow:wi,onStopAutoflow:Ti},gd=(0,ud.connect)(df,uf)(pf);var Js=require("react"),fd=require("react-redux"),Li=T(require("classnames"));var Ii=require("react/jsx-runtime"),Ai=()=>(0,Ii.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,Ii.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 md={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 Be=require("react/jsx-runtime"),gf=({entities:t})=>{let e=S("EntitiesWidgetList",md),[o,n]=(0,Js.useState)(void 0),s=(0,fd.useDispatch)(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),Jo(a.text),s(ie({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,Js.useEffect)(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:(0,Be.jsx)("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>(0,Be.jsxs)("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[(0,Be.jsx)("span",{className:e.entityText,children:a.text}),(0,Be.jsxs)("span",{className:e.iconWrapper,children:[(0,Be.jsx)("span",{className:(0,Li.default)(e.icon),children:(0,Be.jsx)(Ai,{})}),(0,Be.jsx)("span",{className:(0,Li.default)(e.icon,o===l&&e.iconClicked),children:(0,Be.jsx)(Ai,{})})]})]},a.text))})},hd=gf;var yd=T(require("classnames")),Mi=require("react"),Bt=require("react-redux");var dn={};j(dn,{enUS:()=>mf,nlNL:()=>ff});var mf={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"}]},ff={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 ot={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};var se=require("react/jsx-runtime"),hf=({suggestion:t})=>{let e=E(dn),o=(0,Bt.useDispatch)(),n=(0,Bt.useSelector)(Vp(t.text)),s=(0,Bt.useSelector)(Wp(t.text)),r=(0,Bt.useSelector)(Gp(t.text)),i=(0,Bt.useSelector)(Vn),{replyOptions:a}=t,l=(0,Mi.useCallback)(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Qs({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=(0,Mi.useCallback)(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(Zs({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return(0,se.jsxs)(O,{onClick:l,className:(0,yd.default)(ot.root,{[ot.isUsed]:n,[ot.hasError]:r}),children:[(0,se.jsx)(D,{children:(0,se.jsxs)(D.Content,{children:[(0,se.jsxs)(D.Title,{className:ot.title,children:[t.text," ",(0,se.jsx)(zn,{className:ot.label,children:"analyse tool"})," ",r&&(0,se.jsx)("span",{className:ot.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&(0,se.jsx)("ul",{className:ot.quickReplies,children:a.map(p=>(0,se.jsx)("li",{className:ot.quickReply,children:p.title},p.title))})]})}),(0,se.jsxs)(O.Actions,{fixed:r||n,children:[a&&a.length>0&&(0,se.jsx)(O.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>(0,se.jsx)(O.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),(0,se.jsx)(O.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Sd=hf;var Oi=require("react/jsx-runtime"),vd=()=>(0,Oi.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,Oi.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 bd=require("react-redux");var _d=require("react");var ce=require("react/jsx-runtime"),yf=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=ys(s),i=E(dn),a=b("showImages"),l=b("fallbackImage"),c=m=>{m.preventDefault(),m.stopPropagation(),n(s)},p=m=>{m.preventDefault(),m.stopPropagation(),o(t)},d=(0,_d.useCallback)(m=>{window.open(r,"_blank"),m.stopPropagation(),m.preventDefault()},[r]);return(0,ce.jsxs)(O,{onClick:c,"data-testid":"edit-suggestion",children:[(0,ce.jsxs)(D,{children:[a&&t.image&&(0,ce.jsx)(D.Image,{src:Ws(t,"small",l||void 0),title:t.title}),(0,ce.jsxs)(D.Content,{children:[t.title&&(0,ce.jsx)(D.Title,{"data-testid":"widget-suggestion-title",children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&(0,ce.jsx)(O.Labels,{labels:t.searchKeywords}),(0,ce.jsx)(D.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),(0,ce.jsxs)(O.Actions,{children:[r&&(0,ce.jsx)(O.ActionButton,{onClick:d,label:i("visitUrl")}),(0,ce.jsx)(O.ActionButton,{primary:!0,onClick:p,label:i("preview")}),(0,ce.jsx)(O.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},xd=yf;var un=require("react/jsx-runtime"),Sf=({contentType:t,lines:e,suggestions:o})=>{let n=he(),s=(0,bd.useSelector)(io),r=a=>{n.send(Yr,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(Ve,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return(0,un.jsx)(un.Fragment,{children:o.map(a=>(0,un.jsx)(xd,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},Cd=Sf;var Ni={};j(Ni,{enUS:()=>vf,nlNL:()=>_f});var vf={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"}]},_f={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var wd={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 Di=require("react/jsx-runtime"),Td=()=>(0,Di.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Di.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 Hi=require("react/jsx-runtime"),Ed=()=>(0,Hi.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,Hi.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"),Ys=(t,e)=>{let o=(0,V.useSelector)(Ee);(0,Rd.useEffect)(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},xf=()=>{let t=E(Ni),e=(0,V.useDispatch)(),o=b("isEmbedded"),n=S("Widget",wd),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=(0,V.useSelector)(yo),d=(0,V.useSelector)(As),u=(0,V.useSelector)(Fp),m=(0,V.useSelector)(ks),f=(0,V.useSelector)(qp),g=(0,V.useSelector)(Wn),x=(0,V.useSelector)(Gt),w=(0,V.useSelector)(Ee),h=(0,V.useSelector)(Vn),y=(0,V.useSelector)(od),_=(0,V.useSelector)(io),C=he(),K=(0,V.useSelector)(jl),H=(0,V.useSelector)(Jp("/admin/personal-collection")),Le=b("adminUrl");if(Ys(()=>(e(cn(h)),e(Xp(h)),()=>{e(Qp(h))}),[e,x,r,h]),Ys(()=>(e(tt(h)),e(Kp(h)),()=>{e(Up(h))}),[e,x,s,h]),Ys(()=>{d.forEach(({type:P})=>{e(P==="entities"?Re():je(P))})},[e,x,g,p]),Ys(()=>(e(ki()),()=>{e(ed())}),[e,x,i,g]),x===!1)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("notSupported")})})},"supported");if(w===!1)return(0,R.jsx)("div",{className:n.loginText,children:(0,R.jsx)("div",{children:(0,R.jsx)(Ns,{isEmbedded:o,loginUrl:Le})})},"login");if(!p||!h||w===null||K||y)return(0,R.jsx)("div",{className:n.stateText,children:(0,R.jsx)("div",{children:(0,R.jsx)("p",{children:t("waiting")})})},"waiting");let B=c||a||l||H;return(0,R.jsx)("div",{className:(0,kd.default)(n.root),"data-testid":"widget",children:(0,R.jsxs)(jn,{className:n.sectionList,children:[B&&(0,R.jsx)(rt,{title:t("actions"),type:"shortcuts",children:(0,R.jsxs)("div",{className:n.shortcutList,children:[c&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-search",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0}),children:[(0,R.jsx)(so,{}),t("linkSearch")]}),a&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-summary",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,R.jsx)(Ed,{}),t("linkSummary")]}),l&&(0,R.jsxs)("button",{className:n.shortcut,"data-testid":"shortcut-knowledge-assist",onClick:()=>C.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,R.jsx)(Td,{}),t("linkKnowledgeSearch")]}),H&&(0,R.jsxs)("a",{className:n.shortcut,target:"_blank",href:H,"data-testid":"shortcut-personal-collection",rel:"noreferrer",children:[(0,R.jsx)(vd,{}),t("linkPersonalcollection")]})]})}),r&&f.length>0&&(0,R.jsx)(rt,{type:"custom-messages","data-testid":"custom-messages",children:(0,R.jsx)(ge,{withDivider:!0,children:f.map(P=>(0,R.jsx)(Sd,{suggestion:P},P.text))})}),s&&u.length>0&&(0,R.jsx)(rt,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:(0,R.jsx)(ge,{withDivider:!0,children:(0,R.jsx)(gd,{})})}),d.map(({type:P,title:J,amount:ve,lines:cr})=>{var wt;switch(P){case"entities":return m&&m.length>0&&(0,R.jsx)(rt,{type:P,title:J,"data-testid":`type-${P}`,children:(0,R.jsx)(hd,{entities:m})},P);default:return((wt=_[P])==null?void 0:wt.fetchState)==="done"&&_[P].suggestions.length>0&&(0,R.jsx)(rt,{type:P,title:J,"data-testid":`type-${P}`,children:(0,R.jsx)(ge,{withDivider:!0,children:(0,R.jsx)(Cd,{lines:cr,contentType:P,suggestions:_[P].suggestions.slice(0,ve)||[]})})},P)}})]})})},Pd=xf;function To(t){let e=new Range;return e.selectNodeContents(t),e}function Id(t,e,o){try{return Ct(t,e,o),!0}catch{return!1}}function er(t){return"tagName"in t&&(t.tagName==="DIV"||t.tagName==="P")}function tr(t){return"tagName"in t&&t.tagName==="BR"}var gn=/[\u200B-\u200D\uFEFF]/g;function Ct(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){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,p=c.replace(gn,""),d=s+p.length,u=e>=s&&e<=d,m=o>=s&&o<=d;if(u){let f=i(c,e-s);f===0&&!m?n.setStartBefore(l):n.setStart(l,f)}m&&(n.setEnd(l,i(c,o-s)),r=!0),s=d;break}case Node.ELEMENT_NODE:{if(tr(l)&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let p=0;p<l.childNodes.length&&(a(l.childNodes[p]),!r);p++);let c=l.lastChild;er(l)&&c&&!er(c)&&!tr(c)&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function mn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r,collapsed:i}=e,a,l,c=0;function p(d){let u=d===o,m=d===s;switch(d.nodeType){case Node.TEXT_NODE:{let f=d.textContent;u&&(a=c+f.substring(0,n).replace(gn,"").length),m&&(l=c+f.substring(0,r).replace(gn,"").length),c+=f.replace(gn,"").length;break}case Node.ELEMENT_NODE:{let f=d.nextSibling===null;tr(d)&&!f&&c++;for(let g=0;g<d.childNodes.length;g++){let x=u&&g===n,w=m&&g===r;if(x&&(a=c),w&&(l=c),l!==void 0||((!x||!i)&&p(d.childNodes[g]),m&&g===r-1&&(l=c),l!==void 0))break}!m&&er(d)&&!f&&c++,m&&(l=c);break}default:break}}if(p(t),l===void 0)throw new Error("Could not determine start and end");return{start:a??l,end:l}}function fn(t,e){if(!t.contains(e.startContainer)||!t.contains(e.endContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,m=d?r:void 0,f=c.textContent.replace(gn,"");u===0&&m===void 0?a+=f:a+=f.substring(u,m);break}case Node.ELEMENT_NODE:{let u=c.nextSibling===null;i===0&&tr(c)&&!u&&(a+=`
4
4
  `);for(let m=p?n:0;m<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[m]),i!==1);m++);!d&&i===0&&er(c)&&!u&&(a+=`
5
- `);break}default:break}d&&i++}return l(t),a}function Ad(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Bt=class extends Ke{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),fn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!Ad(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Ad(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return mn(this.element,e);let o=this.lastKnownSelection;if(o&&Id(this.element,o.start,o.end))return o;let n=wo(this.element);return n.collapse(!1),mn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return fn(this.element,Ct(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(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 Bi=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Fi=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()}},Ki=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),k.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Fi(e,this.deepdeskUrl,{debug:!0}):new Bi(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(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,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Ld=Ki;var To=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Ui=t=>new Promise(e=>{setTimeout(e,t)});var Eo=class extends To{name="ClientError"},zi=class extends To{name="ServerError"},Ie=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=_=>_ instanceof TypeError,retryOnResponse:m=_=>_.status>=500,version:f="v1",...g}=o,x={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(x.headers={...x.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(x.headers={...x.headers,"X-Deepdesk-API-Version":f});let w=c,h=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let y=async()=>(w--,a(i,x).then(async _=>m(_)&&!r.isAborted&&w>0?(await Ui(p),y()):_.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),y()):_).catch(async _=>{if(u(_)&&!r.isAborted&&w>0)return await Ui(p),y();throw _}));y().then(_=>_.json().catch(()=>null).then(C=>{_.status>=500?s(new zi("Server Error",C)):_.status===401?s(new Eo("Unauthorized",C)):_.status===403?s(new Eo("Forbidden",C)):_.status===404?s(new Eo("Not Found",C)):_.status>=400&&s(new Eo("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).catch(_=>{s(_)})})}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 bf;(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||={})})(bf||={});function or(t){return{...M(t),tags:t.tags}}var nt=class t{constructor(e,o={}){this.options=o;this.client=new Ie(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),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 or(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return M(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return M(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return M(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 or(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 or(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=>or(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=>({...M(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 M(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 M(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return M(o)}async knowledgeAssist(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 M(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return M(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 M(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(wa);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 hn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Wr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,M(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 Cf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Cf||={});var yn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ie(e,o)}client;streams={};logger=k;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return M(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return M(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 M(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return M(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new hn(`${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 ir=require("@reduxjs/toolkit");var Od=require("@reduxjs/toolkit");var Md={startTime:null,stopTime:null},Nd=(0,Od.createSlice)({name:"handlingTime",initialState:Md,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(I,()=>Md)}}),{handlingTimeStart:Dd,handlingTimeStop:nr,handlingTimeReset:Hd}=Nd.actions,Bd=Nd.reducer;var Fd=(t={})=>{let e={onAuthError:co(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var rr=require("@reduxjs/toolkit");var sr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Ft=(0,rr.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 sr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),wf=(0,rr.createSlice)({name:"styleSuggestions",initialState:sr,reducers:{},extraReducers:t=>{t.addCase(Ft.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Ft.rejected,e=>{e.fetchState="error"}).addCase(Ft.fulfilled,(e,o)=>{e.fetchState="done",at(e.list,o.payload)||(e.list=o.payload)}).addCase(Pt,e=>{e.list=sr.list}).addCase(I,()=>sr)}}),Kd=wf.reducer;var Ud=(t={})=>{let e,o=!0,n={getStyleSuggestions:Ft,debounce:500,...t};return s=>r=>i=>{var m;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function Tf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var zd=(t={})=>{let e={getTextSuggestions:je,getAutocompleteSuggestions:Wo,debounce:200,check:So,...t},o;return n=>s=>r=>{var g;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(g=l.conversation.current)==null?void 0:g.id,u=r.type===xs.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:m}}=l;return Tf(m,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let x=Gt(l);x===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(x))},u?0:e.debounce)),a}};var jd=Ft.fulfilled.toString();function Ef(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 qd=t=>e=>o=>n=>{var c;if(n.type!==jd){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=Ef(s,i);n.type===jd&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var kf=(0,ir.combineReducers)({activeSuggestion:ec,answer:zc,auth:mc,autoflows:zp,conversation:La,contentTypes:Ec,customMessages:Zp,exchangeToken:td,entities:Ic,handlingTime:Bd,info:El,input:Pr.reducer,overlayInput:Y.reducer,settings:Ra,profile:Vc,search:Ll,summary:Dc,styleSuggestions:Kd,ui:rc,textSuggestions:$l});function Vd(t){return(0,ir.configureStore)({reducer:kf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Fd(),zd({debounce:200}),Ud({debounce:500}),qd(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Rf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Pf=t=>e=>o=>n=>{var a;let s=e.getState(),r=Tr("inlineSuggestions")(s);switch(n.type){case qe.toString():{let l=zl(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 co.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:Rf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Yn.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 No.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case ns.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 Re.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case We.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case ie.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case es.toString():t.handleKeyDown(n.payload);break;case Pt.toString():t.logSendMessage(n.payload);break;case ts.toString():t.logSendEditSuggestionMessage(n.payload);break;case os.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Pt.toString():t.handleAfterSendMessage(n.payload);break;case Go.toString():t.onUpdateShowTabHint(n.payload);break;case nr.toString():t.logHandlingTime();break;case we.toString():{r&&(e.dispatch(Be([])),e.dispatch(ct()));break}default:break}return i},Wd=Pf;function ji(t){return t.toISOString().replace("T"," ").replace("Z","")}function Gd(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:ji(o),timeStop:ji(n)}}function qi(t,e,o){var H,Le,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:m,textSuggestions:f,offeredTextSuggestions:g}}=e[t],x=n.length,h=f.reduce((P,{text:J,searchTerm:ve})=>P+J.length-(ve?ve.length:0),0),y=c??Date.now(),_=(Date.now()-y)/1e3+(p||0),C=s/_,K=f.reduce((P,{searchTerm:J})=>P+(J?J.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:m,lenTextTyped:s+K,lenTextTotal:x,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:_,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:g.filter(P=>P.source==="gpt").length}],agentId:(H=e.info.agentInfo)==null?void 0:H.agentId,agentName:(Le=e.info.agentInfo)==null?void 0:Le.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function $d(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?$d(n,e):null}function Xd(t,e){return $d(t,e)}function Qd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function If(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ar(t){return If(t)&&(St(t)||is(t))}var Zd=(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 Af(t){return t.offsetParent!==null}function Jd(t){if(!Af(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 lr(t,e,o=100){let n=Jd(t);e({isVisible:n});let s=setInterval(()=>{let r=Jd(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var $=require("react/jsx-runtime"),Yd=Zd("showTabHint",!0),Sn=class t{static version="10.4.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new nt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Wd({emit:(d,u,m)=>this.emit(d,u,m),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>Yd.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new yn(o)}),this.store=Vd(p),this.broadcastEvents=new Ld({debug:!0,deepdeskUrl:c,eventMap:fc(this.store),createCustomChannel:l}),this.store.dispatch(Oo),this.store.dispatch(Go(Yd.value())),this.store.dispatch(Oo({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(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(co(null)),this.store.dispatch(ft()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Ee(n)&&lc(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(kr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Gn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch($n({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Rr(e))).payload}async postMessages(e){return(await this.store.dispatch(Qn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Xn(e))).payload}resetConversation(){this.store.dispatch(I()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(We());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Oo(e))}setVisitorInfo(e){this.store.dispatch(Tl(e))}async setAgentInfo(e){await this.store.dispatch(zo(e))}async setAgentSettings(e){await this.store.dispatch(Gr(e))}async getAgentSettings(){return(await this.store.dispatch($r())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(xs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(os(e))}notifyKeyDown(e){this.store.dispatch(es(e))}notifyPaste(e,o){this.store.dispatch(Va({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(ja(e))}notifyExternalSuggestion(e){this.store.dispatch(we(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Wl(e.contentType,e.suggestions)),this.store.dispatch(qe({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(mt({collapse:!1})),this.inputMediator&&this.store.dispatch(Ha({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Be([])))}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(qa(Jn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ka()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(za());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(No()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(Do(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(Do(-1)),this.store.dispatch(No()),e.preventDefault()):o||(this.store.dispatch(mt({collapse:!0})),this.store.dispatch(nc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(Go(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(u)&&(this.store.dispatch(we({text:m.text,suggestion:m,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(Wa()),this.store.dispatch(Be([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(Dd()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(nr()))}logSendMessage(e){let o=qi("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=qi("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Fa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Gd(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Hd())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(Pt(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]=At(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=At(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return It(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{(0,Ae.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(!ar(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:m,inputMediator:f,closestScrollSelector:g,appendOverlayTo:x,inlineSuggestions:w}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:d,inlineSuggestions:w}),o.automaticHandlingTime&&this.setupHandlingTime(e),It(e),this.inputMediator=f||(St(e)?new Ue(e):new Bt(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ga({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",y=>{this.notifyKeyDown(y)}),this.inputMediator.on("paste",({pastedText:y,selectionText:_})=>{this.notifyPaste(y,_)}),this.inputMediator.on("cut",({selectionText:y})=>{this.notifyCut(y)}),w){if(St(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let y=this.createInlineContainer(e,"deepdesk-caret");(0,Ae.render)((0,$.jsx)(bo,{store:this.store,customStyles:n,children:(0,$.jsx)(ao,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(rp,{})})}),y),this.inputMediator.on("caret",_=>{this.store.dispatch(Be([])),_?(y.style.display="block",y.style.top=`${_.top}px`,y.style.left=`${_.left}px`):y.style.display="none"})}else{let y=g&&Xd(e,g)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:x,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:x},n==null?void 0:n.suggestionsRootNode);(0,Ae.render)((0,$.jsx)(bo,{store:this.store,customStyles:n,children:(0,$.jsx)(ao,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Dp,{inputElement:e})})}),_),(0,Ae.render)((0,$.jsx)(bo,{store:this.store,customStyles:n,children:(0,$.jsx)(ao,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(mp,{})})}),C)}(0,Ae.render)((0,$.jsx)(bo,{store:this.store,customStyles:n,children:(0,$.jsx)(ao,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Qc,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(Ir(y))},500):this.store.dispatch(Ir(y))}),this.inputMediator.on("disabled",()=>{var y;(y=this.inputMediator)==null||y.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(io(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(io(!0))),this.store.dispatch(Ba({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var y;this.refresh(),this.broadcastEvents.setSessionId((y=this.state.conversation.current)==null?void 0:y.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,Ae.render)((0,$.jsx)(bo,{store:this.store,customStyles:n,children:(0,$.jsx)(ao,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Pd,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Ae.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=lr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Qd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(nn());let e=ho(this.state);e&&this.store.dispatch(Oo({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(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=As(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Re()):this.store.dispatch(je(n))})}catch(n){this.handleError(n)}}};async function eu(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 tu(t,e,o={}){let n=o.replace?Ct(t,o.replace.start,o.replace.end):wo(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
5
+ `);break}default:break}d&&i++}return l(t),a}function Ad(t){return t.top!==0||t.left!==0||t.height!==0||t.width!==0}var Ft=class extends Ke{observer;lastKnownSelection=null;getRootNode(){return this.element.getRootNode()}getText(){let e=new Range;return e.selectNodeContents(this.element),fn(this.element,e)}getHTML(){return this.element.innerHTML||""}getRange(){var r;let e=this.getRootNode();if(e.activeElement!==this.element)return null;let o="getSelection"in e?e.getSelection():window.getSelection();if(!o)return null;let n="getComposedRanges"in o&&e instanceof ShadowRoot?(r=o.getComposedRanges(e))==null?void 0:r[0]:o.rangeCount>0?o.getRangeAt(0):null;if(!n)return null;let s=this.element.ownerDocument.createRange();return s.setStart(n==null?void 0:n.startContainer,n==null?void 0:n.startOffset),s.setEnd(n==null?void 0:n.endContainer,n==null?void 0:n.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let e=this.getRange();if(!e||!e.collapsed||!("getBoundingClientRect"in e))return null;let o=e.getBoundingClientRect();return!Ad(o)&&(e.insertNode(this.element.ownerDocument.createTextNode("\u2060")),o=e.getBoundingClientRect(),e.deleteContents(),!Ad(o))?null:{top:o.top+o.height,left:o.left}}getSelection(){let e=this.getRange();if(e)return mn(this.element,e);let o=this.lastKnownSelection;if(o&&Id(this.element,o.start,o.end))return o;let n=To(this.element);return n.collapse(!1),mn(this.element,n)}getSelectedText(){let{start:e,end:o}=this.getSelection();return fn(this.element,Ct(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);return(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 Bi=class{constructor(e){this.name=e;this.broadcastChannel=new BroadcastChannel(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Fi=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()}},Ki=class{constructor(e){this.params=e;this.deepdeskUrl=e.deepdeskUrl,this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}sessionId;deepdeskUrl;channel;defaultChannel;eventMap;get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(e){this.sessionId!==e&&(this.cleanup(),k.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.params.createCustomChannel?this.params.createCustomChannel(e):this.isCrossOrigin?new Fi(e,this.deepdeskUrl,{debug:!0}):new Bi(e),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&s.data.channel===e&&(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,channel:this.sessionId})}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},Ld=Ki;var Eo=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Ui=t=>new Promise(e=>{setTimeout(e,t)});var ko=class extends Eo{name="ClientError"},zi=class extends Eo{name="ServerError"},Ie=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}request(e,o={}){return new Promise((n,s)=>{let r={isAborted:!1,reject:s},i=`${this.baseUrl}${e}`,a=this.fetch,{abortLatest:l=!1,attempts:c=1,retryDelay:p=500,refreshTokenOn401:d=!0,retryOnError:u=_=>_ instanceof TypeError,retryOnResponse:m=_=>_.status>=500,version:f="v1",...g}=o,x={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(x.headers={...x.headers,"X-CSRFToken":this.csrfToken}),typeof f=="string"&&(x.headers={...x.headers,"X-Deepdesk-API-Version":f});let w=c,h=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&l&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=r;let y=async()=>(w--,a(i,x).then(async _=>m(_)&&!r.isAborted&&w>0?(await Ui(p),y()):_.status===401&&d===!0&&h===!1?(h=!0,await this.refreshToken(),y()):_).catch(async _=>{if(u(_)&&!r.isAborted&&w>0)return await Ui(p),y();throw _}));y().then(_=>_.json().catch(()=>null).then(C=>{_.status>=500?s(new zi("Server Error",C)):_.status===401?s(new ko("Unauthorized",C)):_.status===403?s(new ko("Forbidden",C)):_.status===404?s(new ko("Not Found",C)):_.status>=400&&s(new ko("Bad Request",C)),delete this.latestRequestByUrl[i],n(C)})).catch(_=>{s(_)})})}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 bf;(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||={})})(bf||={});function or(t){return{...M(t),tags:t.tags}}var nt=class t{constructor(e,o={}){this.options=o;this.client=new Ie(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),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 or(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return M(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return M(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return M(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 or(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 or(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=>or(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=>({...M(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 M(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 M(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,U(e),{version:"v2"});return M(o)}async knowledgeAssist(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 M(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return M(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 M(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(wa);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 hn=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Wr(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,M(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 Cf;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(Cf||={});var yn=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ie(e,o)}client;streams={};logger=k;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return M(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,U(o));return M(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 M(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",U(e));return M(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new hn(`${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 ir=require("@reduxjs/toolkit");var Od=require("@reduxjs/toolkit");var Md={startTime:null,stopTime:null},Nd=(0,Od.createSlice)({name:"handlingTime",initialState:Md,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(I,()=>Md)}}),{handlingTimeStart:Dd,handlingTimeStop:nr,handlingTimeReset:Hd}=Nd.actions,Bd=Nd.reducer;var Fd=(t={})=>{let e={onAuthError:po(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};var rr=require("@reduxjs/toolkit");var sr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Kt=(0,rr.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 sr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),wf=(0,rr.createSlice)({name:"styleSuggestions",initialState:sr,reducers:{},extraReducers:t=>{t.addCase(Kt.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Kt.rejected,e=>{e.fetchState="error"}).addCase(Kt.fulfilled,(e,o)=>{e.fetchState="done",at(e.list,o.payload)||(e.list=o.payload)}).addCase(Pt,e=>{e.list=sr.list}).addCase(I,()=>sr)}}),Kd=wf.reducer;var Ud=(t={})=>{let e,o=!0,n={getStyleSuggestions:Kt,debounce:500,...t};return s=>r=>i=>{var m;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((m=c.conversation.current)==null?void 0:m.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function Tf(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var zd=(t={})=>{let e={getTextSuggestions:je,getAutocompleteSuggestions:Wo,debounce:200,check:vo,...t},o;return n=>s=>r=>{var g;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(g=l.conversation.current)==null?void 0:g.id,u=r.type===xs.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:m}}=l;return Tf(m,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let x=$t(l);x===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(x))},u?0:e.debounce)),a}};var jd=Kt.fulfilled.toString();function Ef(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 qd=t=>e=>o=>n=>{var c;if(n.type!==jd){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(c=r.conversation)==null?void 0:c.current;if(s===i)return;let l=Ef(s,i);n.type===jd&&l.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var kf=(0,ir.combineReducers)({activeSuggestion:ec,answer:zc,auth:mc,autoflows:zp,conversation:La,contentTypes:Ec,customMessages:Zp,exchangeToken:td,entities:Ic,handlingTime:Bd,info:El,input:Pr.reducer,overlayInput:Y.reducer,settings:Ra,profile:Vc,search:Ll,summary:Dc,styleSuggestions:Kd,ui:rc,textSuggestions:$l});function Vd(t){return(0,ir.configureStore)({reducer:kf,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),Fd(),zd({debounce:200}),Ud({debounce:500}),qd(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Rf=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Pf=t=>e=>o=>n=>{var a;let s=e.getState(),r=Tr("inlineSuggestions")(s);switch(n.type){case qe.toString():{let l=zl(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 po.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:Rf(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Yn.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 Do.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case ns.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 Re.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case We.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{summary:n.payload.summary}});break;case ie.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case es.toString():t.handleKeyDown(n.payload);break;case Pt.toString():t.logSendMessage(n.payload);break;case ts.toString():t.logSendEditSuggestionMessage(n.payload);break;case os.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Pt.toString():t.handleAfterSendMessage(n.payload);break;case Go.toString():t.onUpdateShowTabHint(n.payload);break;case nr.toString():t.logHandlingTime();break;case we.toString():{r&&(e.dispatch(Oe([])),e.dispatch(ct()));break}case Oe.toString():{r&&n.payload.length>0&&e.dispatch(It(0));break}default:break}return i},Wd=Pf;function ji(t){return t.toISOString().replace("T"," ").replace("Z","")}function Gd(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:ji(o),timeStop:ji(n)}}function qi(t,e,o){var H,Le,B;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:p,pastes:d,cuts:u,deletions:m,textSuggestions:f,offeredTextSuggestions:g}}=e[t],x=n.length,h=f.reduce((P,{text:J,searchTerm:ve})=>P+J.length-(ve?ve.length:0),0),y=c??Date.now(),_=(Date.now()-y)/1e3+(p||0),C=s/_,K=f.reduce((P,{searchTerm:J})=>P+(J?J.length:0),0);return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:d,cuts:u,deletions:m,lenTextTyped:s+K,lenTextTotal:x,lenTextAssisted:h,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:_,charsPerSecond:C,numPastes:l,textSuggestionsV2:f,suggestionsCounters:[{source:"gpt",countOffered:g.filter(P=>P.source==="gpt").length}],agentId:(H=e.info.agentInfo)==null?void 0:H.agentId,agentName:(Le=e.info.agentInfo)==null?void 0:Le.agentName,agentEmail:(B=e.info.agentInfo)==null?void 0:B.agentEmail}}function $d(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?$d(n,e):null}function Xd(t,e){return $d(t,e)}function Qd(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function If(t){return typeof t=="object"&&t!==null&&"tagName"in t}function ar(t){return If(t)&&(St(t)||is(t))}var Zd=(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 Af(t){return t.offsetParent!==null}function Jd(t){if(!Af(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 lr(t,e,o=100){let n=Jd(t);e({isVisible:n});let s=setInterval(()=>{let r=Jd(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}var $=require("react/jsx-runtime"),Yd=Zd("showTabHint",!0),Sn=class t{static version="10.4.1-beta.0";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a,createCustomChannel:l}){let c=e.replace(/\/api$/,"");this.deepdeskApi=new nt(c,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let p={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[Wd({emit:(d,u,m)=>this.emit(d,u,m),handleAfterSendMessage:d=>this.handleAfterSendMessage(d),handleInputChanged:d=>this.handleInputChanged(d),handleKeyDown:d=>this.handleKeyDown(d),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:d=>this.logSendMessage(d),logSendEditSuggestionMessage:d=>this.logSendEditMessage(d),onUpdateShowTabHint:d=>Yd.update(d),sendEvent:(d,u)=>this.deepdeskApi.sendEvent(d,u)})]};o&&Object.assign(p,{deepdeskBrokerAPI:new yn(o)}),this.store=Vd(p),this.broadcastEvents=new Ld({debug:!0,deepdeskUrl:c,eventMap:fc(this.store),createCustomChannel:l}),this.store.dispatch(No),this.store.dispatch(Go(Yd.value())),this.store.dispatch(No({locale:s,adminUrl:c,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(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(po(null)),this.store.dispatch(ft()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Ee(n)&&lc(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(kr({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Gn(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch($n({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Rr(e))).payload}async postMessages(e){return(await this.store.dispatch(Qn(e))).payload}async updateConversation(e){return(await this.store.dispatch(Xn(e))).payload}resetConversation(){this.store.dispatch(I()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(We());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(No(e))}setVisitorInfo(e){this.store.dispatch(Tl(e))}async setAgentInfo(e){await this.store.dispatch(zo(e))}async setAgentSettings(e){await this.store.dispatch(Gr(e))}async getAgentSettings(){return(await this.store.dispatch($r())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.handleInputChanged(this.inputMediator.getText());let e=[];return this.store.dispatch(xs()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(os(e))}notifyKeyDown(e){this.store.dispatch(es(e))}notifyPaste(e,o){this.store.dispatch(Va({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(ja(e))}notifyExternalSuggestion(e){this.store.dispatch(we(e)),this.store.dispatch(ct())}notifyEditSuggestion(e){this.store.dispatch(Wl(e.contentType,e.suggestions)),this.store.dispatch(qe({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(mt({collapse:!1})),this.inputMediator&&this.store.dispatch(Ha({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Oe([])))}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(qa(Jn(e))),e.key!=="Tab"&&!this.settings.showTextSuggestions)return;let c=()=>{o||!a||r&&(e.shiftKey||(this.store.dispatch(Ka()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault()))},p=()=>{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(za());let{selectedSuggestionIndex:d}=this.state.input;e.preventDefault(),!i&&(d===-1?this.store.dispatch(Do()):this.stageSelectedSuggestion({inputType:"arrow"}))};switch(e.key){case"Up":case"ArrowUp":i?p():c();return;case"Down":case"ArrowDown":{i?c():p();return}case"Esc":case"Escape":{i&&l&&this.store.dispatch(It(-1)),this.state.input.selectedSuggestionIndex!==-1?(this.store.dispatch(It(-1)),this.store.dispatch(Do()),e.preventDefault()):o||(this.store.dispatch(mt({collapse:!0})),this.store.dispatch(nc(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:d}=this.state.input,u=d.text.substring(0,d.selection.end),{tabCompletionSuggestion:m}=this.state.input;this.store.dispatch(Go(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):!i&&this.settings.showTabCompletion&&m&&m.text.startsWith(u)&&(this.store.dispatch(we({text:m.text,suggestion:m,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(Wa()),this.store.dispatch(Oe([]))}handlingTimeStart(){this.state.handlingTime.startTime||(k.info("Start handling time"),this.store.dispatch(Dd()))}handlingTimeStop(){this.state.handlingTime.startTime&&(k.info("Stop handling time"),this.store.dispatch(nr()))}logSendMessage(e){let o=qi("input",this.state,{version:this.version});e&&(Object.assign(o,{text:e}),Object.assign(o,{lenTextTotal:e.length})),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=qi("overlayInput",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.store.dispatch(Fa(this.state.overlayInput.metrics))}logHandlingTime(){let e=Gd(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(Hd())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(ct()),this.store.dispatch(Pt(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]=Lt(o,n);return r.setAttribute("translate","no"),r.dataset.testid=e,s&&r.classList.add(s),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(r),i(),r.remove()}),r}createInlineContainer(e,o){var i;let n=document.createElement("div");n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.height="0px",n.style.width="0px";let s=document.createElement("div");s.style.display="none",s.style.position="absolute",s.style.height="0px",s.style.width="0px",s.style.backgroundColor="red",n.appendChild(s);let r=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;if(r){let[a,l]=Lt(r,{appendTo:document.body});a.dataset.testid=o,a.style.zIndex="2",a.appendChild(n),this.unmountHandlers.push(()=>{(0,Ae.unmountComponentAtNode)(s),l()})}else document.body.appendChild(n);return s}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return At(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,s.setAttribute("translate","no"),o.appendChild(s),this.unmountHandlers.push(()=>{(0,Ae.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(!ar(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:m,inputMediator:f,closestScrollSelector:g,appendOverlayTo:x,inlineSuggestions:w}=o;if(this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:m,isEmbedded:d,inlineSuggestions:w}),o.automaticHandlingTime&&this.setupHandlingTime(e),At(e),this.inputMediator=f||(St(e)?new Ue(e):new Ft(e)),this.inputMediator.on("change",({plainText:y})=>{this.notifyInputChanged(y)}),this.inputMediator.on("updated",()=>{this.inputMediator&&this.store.dispatch(Ga({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()}))}),this.inputMediator.on("keydown",y=>{this.notifyKeyDown(y)}),this.inputMediator.on("paste",({pastedText:y,selectionText:_})=>{this.notifyPaste(y,_)}),this.inputMediator.on("cut",({selectionText:y})=>{this.notifyCut(y)}),w){if(St(e))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let y=this.createInlineContainer(e,"deepdesk-caret");(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(rp,{})})}),y),this.inputMediator.on("caret",_=>{this.store.dispatch(Oe([])),_?(y.style.display="block",y.style.top=`${_.top}px`,y.style.left=`${_.left}px`):y.style.display="none"})}else{let y=g&&Xd(e,g)||void 0,_=this.overlayContainerFactory("deepdesk-tab-completion",y||e,{appendTo:x,closestScrollElement:y,mirrorOverflow:!0,onRemove:()=>this.unmount()},n==null?void 0:n.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",y||e,{appendTo:x},n==null?void 0:n.suggestionsRootNode);(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Dp,{inputElement:e})})}),_),(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(mp,{})})}),C)}(0,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Qc,{})})}),this.createContainer("deepdesk-overlays"));let h;this.inputMediator.on("selection",y=>{clearTimeout(h),y===null?h=setTimeout(()=>{y!==null&&this.store.dispatch(Ir(y))},500):this.store.dispatch(Ir(y))}),this.inputMediator.on("disabled",()=>{var y;(y=this.inputMediator)==null||y.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(ao(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(ao(!0))),this.store.dispatch(Ba({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var y;this.refresh(),this.broadcastEvents.setSessionId((y=this.state.conversation.current)==null?void 0:y.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,Ae.render)((0,$.jsx)(Co,{store:this.store,customStyles:n,children:(0,$.jsx)(lo,{broadcastEvents:this.broadcastEvents,children:(0,$.jsx)(Pd,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Ae.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=lr(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Qd(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(nn());let e=yo(this.state);e&&this.store.dispatch(No({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeAssistForAgents,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(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=As(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(Re()):this.store.dispatch(je(n))})}catch(n){this.handleError(n)}}};async function eu(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 tu(t,e,o={}){let n=o.replace?Ct(t,o.replace.start,o.replace.end):To(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),o.insertBRs!==!1?e.split(`
6
6
  `).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}):n.insertNode(document.createTextNode(e))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?Ct(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()}})}async function ou(t,e){let o;t.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0}));let n=()=>{let r=(t.ownerDocument.defaultView??window).getSelection();if(!r)return;let i=r.getRangeAt(0);i&&(i.deleteContents(),o=document.createElement("span"),i.insertNode(o),e.split(`
7
7
  `).reverse().forEach((a,l)=>{l>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(a))}),i.collapse(!1))};return Promise.resolve(n()).then(()=>{if(t.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:e,bubbles:!0,cancelable:!0})),t.focus(),!!o)try{o.scrollIntoView&&o.scrollIntoView({block:"nearest",inline:"nearest"})}finally{o&&o.remove()}})}function nu(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function su(t,e,o){await new nt(t).authenticateWithKey(e,o)}async function ru(t){let o=await new Ie(t).get("/platform/config/",{version:null});return M(o)}async function Lf(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 iu(t,e){let o=await Lf(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}0&&(module.exports={Card,Chip,ContentEditableInput,DeepdeskAPI,DeepdeskSDK,HTTPClient,InputMediator,InputType,KeyboardHint,Label,Locale,Section,SectionList,Sources,Suggestion,SuggestionList,TextAreaInput,ToggleButton,attachFile,authenticateWithKey,createFullRange,createOverlayContainer,createRangeFromOffsets,escapeHTML,fetchPlatformConfig,formatTextMarkup,getRangeOffsets,getRangeText,insertCKEditor,isSupportedInputElement,updateContentEditable,updateTextArea,useStyles,waitForElementVisibilityChange});