@deepdesk/deepdesk-sdk 12.0.2-beta.0 → 12.0.2-beta.2

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.
@@ -10,7 +10,7 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
10
10
  The error may be correlated with this previous error:
11
11
  ${ao.current.stack}
12
12
 
13
- `),ut}Xi(()=>{ao.current=void 0,Y.current=void 0,we.current=Qt});let Zt=(0,de.useMemo)(()=>de.default.createElement(g,Wn({},Qt,{ref:_})),[_,g,Qt]);return(0,de.useMemo)(()=>v?de.default.createElement(G.Provider,{value:hr},Zt):Zt,[G,Zt,hr])}let C=de.default.memo(x);if(C.WrappedComponent=g,C.displayName=x.displayName=h,l){let N=de.default.forwardRef(function(D,G){return de.default.createElement(C,Wn({},D,{reactReduxForwardedRef:G}))});return N.displayName=h,N.WrappedComponent=g,(0,Kg.default)(N,g)}return(0,Kg.default)(C,g)}}var $n=XL;var Da=w(H());function YL({store:e,context:t,children:n,serverState:r,stabilityCheck:o="once",noopCheck:i="once"}){let s=(0,Da.useMemo)(()=>{let u=Gc(e);return{store:e,subscription:u,getServerState:r?()=>r:void 0,stabilityCheck:o,noopCheck:i}},[e,r,o,i]),a=(0,Da.useMemo)(()=>e.getState(),[e]);Xi(()=>{let{subscription:u}=s;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),a!==e.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[s,a]);let l=t||Je;return Da.default.createElement(l.Provider,{value:s},n)}var Wg=YL;function Yc(e=Je){let t=e===Je?Tc:Oa(e);return function(){let{store:r}=t();return r}}var $g=Yc();function n1(e=Je){let t=e===Je?$g:Yc(e);return function(){return t().dispatch}}var X=n1();Lx(o1.useSyncExternalStoreWithSelector);t1(r1.useSyncExternalStore);Cx(Mg.unstable_batchedUpdates);var Fa=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Fa||{});var QL={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!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,floatingMenu:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!1,adminUrl:void 0,productName:"Deepdesk"},i1=Q({name:"settings",initialState:QL,reducers:{set(e,t){Object.entries(t.payload).forEach(n=>{let[r,o]=n;typeof o!="undefined"&&(e[r]=o)})}}}),{set:Qc}=i1.actions,qg=e=>t=>t.settings[e],V=e=>M(qg(e)),s1=i1.reducer;var ZL={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},rt=e=>e.auth.isLoggedIn,a1=e=>e.auth.loginFetchState,l1=e=>e.auth.verifyFetchState,u1=e=>e.auth.showLoginOverlay,qn=K("auth/validate",(e,t)=>k(void 0,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),c1=K("auth/requestLogin",(n,r)=>k(void 0,[n,r],function*({email:e},t){let{deepdeskAPI:o}=t.extra;return o.requestLoginByEmail(e)})),Ha=K("auth/verifyLoginToken",(n,r)=>k(void 0,[n,r],function*({token:e},t){let{deepdeskAPI:o}=t.extra;return o.verifyLoginToken(e)})),d1=Q({name:"auth",initialState:ZL,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(qn.pending,t=>{t.loginFetchState="loading"}),e.addCase(qn.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(qn.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(Ha.pending,t=>{t.verifyFetchState="loading"}),e.addCase(Ha.rejected,t=>{t.verifyFetchState="error"}),e.addCase(Ha.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Qi,setShowLoginOverlay:f1}=d1.actions,p1=d1.reducer;function Gn(){}Gn.prototype={diff:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=r.callback;typeof r=="function"&&(o=r,r={}),this.options=r;var i=this;function s(y){return o?(setTimeout(function(){o(void 0,y)},0),!0):y}t=this.castInput(t),n=this.castInput(n),t=this.removeEmpty(this.tokenize(t)),n=this.removeEmpty(this.tokenize(n));var a=n.length,l=t.length,u=1,c=a+l;r.maxEditLength&&(c=Math.min(c,r.maxEditLength));var m=[{newPos:-1,components:[]}],d=this.extractCommon(m[0],n,t,0);if(m[0].newPos+1>=a&&d+1>=l)return s([{value:this.join(n),count:n.length}]);function f(){for(var y=-1*u;y<=u;y+=2){var g=void 0,p=m[y-1],h=m[y+1],S=(h?h.newPos:0)-y;p&&(m[y-1]=void 0);var x=p&&p.newPos+1<a,T=h&&0<=S&&S<l;if(!x&&!T){m[y]=void 0;continue}if(!x||T&&p.newPos<h.newPos?(g=eI(h),i.pushComponent(g.components,void 0,!0)):(g=p,g.newPos++,i.pushComponent(g.components,!0,void 0)),S=i.extractCommon(g,n,t,y),g.newPos+1>=a&&S+1>=l)return s(JL(i,g.components,n,t,i.useLongestToken));m[y]=g}u++}if(o)(function y(){setTimeout(function(){if(u>c)return o();f()||y()},0)})();else for(;u<=c;){var v=f();if(v)return v}},pushComponent:function(t,n,r){var o=t[t.length-1];o&&o.added===n&&o.removed===r?t[t.length-1]={count:o.count+1,added:n,removed:r}:t.push({count:1,added:n,removed:r})},extractCommon:function(t,n,r,o){for(var i=n.length,s=r.length,a=t.newPos,l=a-o,u=0;a+1<i&&l+1<s&&this.equals(n[a+1],r[l+1]);)a++,l++,u++;return u&&t.components.push({count:u}),t.newPos=a,l},equals:function(t,n){return this.options.comparator?this.options.comparator(t,n):t===n||this.options.ignoreCase&&t.toLowerCase()===n.toLowerCase()},removeEmpty:function(t){for(var n=[],r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n},castInput:function(t){return t},tokenize:function(t){return t.split("")},join:function(t){return t.join("")}};function JL(e,t,n,r,o){for(var i=0,s=t.length,a=0,l=0;i<s;i++){var u=t[i];if(u.removed){if(u.value=e.join(r.slice(l,l+u.count)),l+=u.count,i&&t[i-1].added){var m=t[i-1];t[i-1]=t[i],t[i]=m}}else{if(!u.added&&o){var c=n.slice(a,a+u.count);c=c.map(function(f,v){var y=r[l+v];return y.length>f.length?y:f}),u.value=e.join(c)}else u.value=e.join(n.slice(a,a+u.count));a+=u.count,u.added||(l+=u.count)}}var d=t[s-1];return s>1&&typeof d.value=="string"&&(d.added||d.removed)&&e.equals("",d.value)&&(t[s-2].value+=d.value,t.pop()),t}function eI(e){return{newPos:e.newPos,components:e.components.slice(0)}}var tI=new Gn;function h1(e,t,n){return tI.diff(e,t,n)}var m1=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,g1=/\S/,y1=new Gn;y1.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!g1.test(e)&&!g1.test(t)};y1.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&m1.test(t[n])&&m1.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var v1=new Gn;v1.tokenize=function(e){var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var o=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),t.push(o))}return t};var nI=new Gn;nI.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var rI=new Gn;rI.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Zc(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Zc=function(t){return typeof t}:Zc=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zc(e)}var oI=Object.prototype.toString,Ua=new Gn;Ua.useLongestToken=!0;Ua.tokenize=v1.tokenize;Ua.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,o=r===void 0?function(i,s){return typeof s=="undefined"?n:s}:r;return typeof e=="string"?e:JSON.stringify(Gg(e,null,null,o),o," ")};Ua.equals=function(e,t){return Gn.prototype.equals.call(Ua,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"))};function Gg(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o,e));var i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];var s;if(oI.call(e)==="[object Array]"){for(t.push(e),s=new Array(e.length),n.push(s),i=0;i<e.length;i+=1)s[i]=Gg(e[i],t,n,r,o);return t.pop(),n.pop(),s}if(e&&e.toJSON&&(e=e.toJSON()),Zc(e)==="object"&&e!==null){t.push(e),s={},n.push(s);var a=[],l;for(l in e)e.hasOwnProperty(l)&&a.push(l);for(a.sort(),i=0;i<a.length;i+=1)l=a[i],s[l]=Gg(e[l],t,n,r,l);t.pop(),n.pop()}else s=e;return s}var Xg=new Gn;Xg.tokenize=function(e){return e.slice()};Xg.join=Xg.removeEmpty=function(e){return e};function S1(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function $r(e,t,n=10){let r=typeof e,o=typeof t;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return r!==o?!1:e==null||r==="string"||r==="number"||r==="boolean"?e===t:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:e.every((i,s)=>$r(i,t[s],n-1)):S1(e)&&S1(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>$r(e[s],t[s],n-1)):!1}function iI(e){return Math.max(...e.map(t=>t.length))}function sI(e,t){let n=e.reduce((r,o)=>{if(o){let i=r[o]?r[o]+1:1;return O(P({},r),{[o]:i})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function w1(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<iI(r);o++){let i=sI(r.map(a=>a[o]),t),s=r.filter(a=>!i.includes(a[o]));if(s.length>=t)r=s;else return{text:r[0].slice(0,o).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var aI=2;function x1(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=w1(e,aI);return n&&n.text!==t?n:e[0]}var lI={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},U=lI;var E1={current:null,isSupported:null},fe=Re("resetConversation"),Zi=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.sessionId)||null},qr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},Ji=e=>e.conversation.isSupported,Yg=K("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.sessionId,e.options)}),Jc=K("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),ed=K("conversation/bySessionId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationBySessionId(e.sessionId,e.options)}),td=K("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=qr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),Qg=K("conversation/upsert",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationBySessionId(e.sessionId).catch(()=>null).then(r=>{if(!r)return n.createConversation(e);let{agentId:o,agentName:i,agentEmail:s,agentNickname:a,tags:l}=e;return n.updateConversation(r.id,{agentId:o,agentEmail:s,agentName:i,agentNickname:a,tags:l})})}),nd=K("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=qr(t.getState());if(!r)throw new Error("No current conversation to update messages");return n.postMessages(r,e.map(o=>P({},o)))}),uI=[Jc.rejected,ed.rejected,td.rejected,nd.rejected].map(e=>e==null?void 0:e.toString()),cI=Q({name:"conversation",initialState:E1,reducers:{},extraReducers:e=>{e.addCase(Yg.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(Jc.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(ed.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(Qg.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(td.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(nd.fulfilled,(t,n)=>{t.current&&(t.current.messages=n.payload)}).addCase(fe,()=>E1).addMatcher(t=>uI.includes(t.type),(t,n)=>{var r;throw U.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),b1=cI.reducer;var Lo={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion: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 Zg(e){let{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}=e;return{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}}var rd=Re("input/replaceText"),Io=Re("input/sendMessage"),od=Re("input/applyImageSuggestion"),ot=Re("input/sendEvent"),C1=Q({name:"input",initialState:Lo,reducers:{setInput(e,t){var i,s;let{beforeInputChange:n}=e,{text:r,html:o}=t.payload;if(e.text=r,e.html=o||null,r==="")e.metrics=Lo.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:a,shiftKey:l,ctrlKey:u,metaKey:c,altKey:m}=n.keyDown;switch(a){case"Enter":l&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:d}=e,f=h1(n.text,d);n.text.length-d.length>1&&e.metrics.deletions.push(...f.filter(v=>v.removed).map(v=>v.value)),e.metrics.numCharsDeleted+=n.text.length-d.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(u||c)break;default:if(!u&&!c&&!m){e.metrics.numCharsTyped+=1;let d=((i=n.selection)==null?void 0:i.start)!==void 0&&((s=n.selection)==null?void 0:s.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;d&&d.length>0&&(e.metrics.numCharsDeleted+=d.length,e.metrics.deletions.push(d))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},setSelection(e,t){t.payload!==null&&($r(e.selection,t.payload)||(e.selection=t.payload))},commitSuggestion(e,t){let n=t.payload,{text:r,suggestion:{source:o,abVariant:i,abTestName:s,trainingJobs:a,sourceText:l,searchTerm:u,text:c},eventMetrics:{inputType:m},replace:d}=n,f=o==="search"||o==="personal-collection-search",v=r.slice(e.text.substring(0,e.selection.start).length);(f||d==="selection")&&(v=r),n.suggestion.source==="search-overlay"&&(v=c),e.metrics.textSuggestions.push({text:v,source:o,abVariant:i,abTestName:s,inputType:m,sourceText:l,trainingJobs:a||[],searchTerm:f?e.text:u}),e.textSuggestions=[],e.selectedSuggestionIndex=-1},offeredTextSuggestion(e,t){let{text:n,suggestion:{source:r}}=t.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:r})},registerKeyDown(e,t){let{key:n}=t.payload;["Control","Meta","Shift","Alt"].includes(n)||(e.beforeInputChange={text:e.text,selection:e.selection,keyDown:t.payload})},registerKeyUp(e,t){},registerCut(e,t){let{metrics:n}=e,r=t.payload;e.metrics=O(P({},e.metrics),{numCharsCut:n.numCharsCut+r.length,cuts:[...n.cuts,r]})},registerPaste(e,t){let{metrics:n}=e,{text:r,selectionText:o}=t.payload,i=n.numCharsDeleted+(o&&o.length?o.length:0),s=o&&o.length?[...n.deletions,o]:n.deletions;e.metrics=O(P({},e.metrics),{numCharsDeleted:i,deletions:s,numCharsPasted:n.numCharsPasted+r.length,numPaste:n.numPaste+1,pastes:[...n.pastes,r]})},selectNextTextSuggestion(e){let t=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<t-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},selectPreviousTextSuggestion(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},selectTextSuggestionByIndex(e,t){e.selectedSuggestionIndex=t.payload},setTextSuggestions(e,t){if(e.selectedSuggestionIndex=-1,e.textSuggestions=t.payload,t.payload.length===0){e.mixedSuggestion=null;return}let n=e.text.substring(0,e.selection.end),r=x1(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Lo.metrics}},extraReducers:e=>{e.addCase(fe,t=>{t.mixedSuggestion=Lo.mixedSuggestion,t.textSuggestions=Lo.textSuggestions,t.selectedSuggestionIndex=Lo.selectedSuggestionIndex,t.metrics=Lo.metrics})}}),es=e=>e.input.text.substring(0,e.input.selection.end),dI=e=>e.input.selection,ts=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},T1=()=>M(dI),{commitSuggestion:rn,offeredTextSuggestion:k1,registerCut:P1,registerKeyDown:R1,registerKeyUp:A1,registerPaste:L1,selectNextTextSuggestion:I1,selectPreviousTextSuggestion:N1,selectTextSuggestionByIndex:id,setInput:sd,setMetrics:O1,setSelection:ad,setTextSuggestions:Xn,resetMetrics:M1}=C1.actions,_1=C1.reducer;function fI(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function re(e){return Array.isArray(e)?e.map(re):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>O(P({},t),{[fI(n)]:re(e[n])}),{}):e}function Jg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ne(e){return Array.isArray(e)?e.map(Ne):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>O(P({},t),{[Jg(n)]:Ne(e[n])}),{}):e}var pI={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,fetchState:"idle"},Ba=e=>{var t,n,r;return{timezone:((t=e.info.visitorInfo)==null?void 0:t.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=e.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((r=e.info.visitorInfo)==null?void 0:r.visitorName)||""}},za=K("info/setAgentInfo",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;if(!e.agentId&&!e.agentNickname)throw new Error("At least provide agentId or agentNickname");let r=yield n.client.get("/apis/admin/session/me/",{version:null}),o={};return r.external_id||(o.external_id=e.agentId),r.nickname||(o.nickname=e.agentNickname),!o.external_id&&!o.nickname?re(r):(yield n.client.patch("/apis/admin/session/me/",o,{version:null}),re(r))})),eh=K("info/setAgentSettings",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.client.get("/apis/admin/session/me/",{version:null}),o=P(P({},typeof r.ui_config=="object"?r.ui_config:{}),e);return yield n.client.patch("/apis/admin/session/me/",{ui_config:o}),o})),th=K("info/getAgentSettings",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.client.get("/apis/admin/session/me/",{version:null})).ui_config})),D1=e=>e.info.agentInfo,F1=e=>e.info.customData,H1=Q({name:"info",initialState:pI,reducers:{setVisitorInfo(e,t){e.visitorInfo=P(P({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload}},extraReducers:e=>{e.addCase(za.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=P(P({},t.agentInfo),n.meta.arg)}).addCase(za.rejected,t=>{t.fetchState="error"}).addCase(za.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=O(P(P({},t.agentInfo),n.meta.arg),{agentDefaultLocale:n.payload.defaultLocale,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""})}).addCase(eh.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(th.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(fe,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:U1,setCustomData:z1}=H1.actions,B1=H1.reducer;var ld={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},j1=e=>e.search.isOpen,V1=e=>e.search.page,K1=e=>e.search.list,W1=e=>e.search.aggregates;function $1(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var No=K("search/getAll",(e,t)=>k(void 0,null,function*(){var a;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(a=r.conversation.current)==null?void 0:a.profileCode;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:s}=yield n.search({profile:o,query:e.query,tags:e.tags,size:e.size,current:e.current,filters:{type:e.type},params:Ba(r)});return{results:i.map(l=>O(P({},l),{source:`search-${l.type.toLowerCase()}`,searchTerm:e.query})),aggregates:s}})),q1=Q({name:"search",initialState:ld,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=ld.fetchState,e.list=ld.list}},extraReducers:e=>{e.addCase(No.pending,t=>{t.fetchState="loading"}).addCase(No.rejected,(t,n)=>{t.fetchState="error",U.error(n.error)}).addCase(No.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(fe,()=>ld)}}),{resetSearch:ud,setIsOpen:Ct,setPage:on}=q1.actions,G1=q1.reducer;var nh="SetCues",ns="ShowLoginOverlay",ja="UserLoggedIn",mI="UserLoggedOut",Gr="ApplySuggestion",rh="ApplyImageSuggestion",gI="ShowCommandPalette",hI=e=>({[nh]:t=>{e.dispatch(O(P({},t),{isBroadcasted:!0}))},[gI]:t=>{e.dispatch(Ct(t.isOpen)),t.page&&e.dispatch(on(t.page))},[ns]:t=>{e.dispatch(f1(t))},[ja]:()=>{e.dispatch(qn())},[mI]:()=>{e.dispatch(qn())},[rh]:t=>{e.dispatch(od({suggestion:t.suggestion}))},[Gr]:t=>{e.dispatch(rn(O(P({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),X1=hI;var Va=w(H()),Q1=w(b()),Y1=Va.default.createContext(null),Oo=({broadcastEvents:e,children:t})=>{let n=Va.default.useMemo(()=>e,[]);return(0,Q1.jsx)(Y1.Provider,{value:n,children:t})},Wt=()=>{let e=(0,Va.useContext)(Y1);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var kd=w(ie()),an=w(H());var bd=w(H());var oh=function(e,t){return oh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},oh(e,t)};function Ka(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");oh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Tt=function(){return Tt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Tt.apply(this,arguments)};function Z1(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function cd(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var dd;(function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(dd||(dd={}));var fd=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var sn;(function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"})(sn||(sn={}));var pd;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(pd||(pd={}));function ih(e){return e.type===sn.literal}function J1(e){return e.type===sn.argument}function md(e){return e.type===sn.number}function gd(e){return e.type===sn.date}function hd(e){return e.type===sn.time}function yd(e){return e.type===sn.select}function vd(e){return e.type===sn.plural}function eE(e){return e.type===sn.pound}function Sd(e){return e.type===sn.tag}function wd(e){return!!(e&&typeof e=="object"&&e.type===pd.number)}function Wa(e){return!!(e&&typeof e=="object"&&e.type===pd.dateTime)}function sh(e){e.forEach(function(t){if(delete t.location,yd(t)||vd(t))for(var n in t.options)delete t.options[n].location,sh(t.options[n].value);else md(t)&&wd(t.style)||(gd(t)||hd(t))&&Wa(t.style)?delete t.style.location:Sd(t)&&sh(t.children)})}function tE(e,t){t===void 0&&(t={}),t=Tt({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new fd(e,t).parse();if(n.err){var r=SyntaxError(dd[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||sh(n.val),n.val}function xd(e,t){var n=t&&t.cache?t.cache:EI,r=t&&t.serializer?t.serializer:xI,o=t&&t.strategy?t.strategy:vI;return o(e,{cache:n,serializer:r})}function yI(e){return e==null||typeof e=="number"||typeof e=="boolean"}function nE(e,t,n,r){var o=yI(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function rE(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.apply(this,r),t.set(o,i)),i}function ah(e,t,n,r,o){return n.bind(t,e,r,o)}function vI(e,t){var n=e.length===1?nE:rE;return ah(e,this,n,t.cache.create(),t.serializer)}function SI(e,t){return ah(e,this,rE,t.cache.create(),t.serializer)}function wI(e,t){return ah(e,this,nE,t.cache.create(),t.serializer)}var xI=function(){return JSON.stringify(arguments)};function lh(){this.cache=Object.create(null)}lh.prototype.get=function(e){return this.cache[e]};lh.prototype.set=function(e,t){this.cache[e]=t};var EI={create:function(){return new lh}},Ed={variadic:SI,monadic:wI};var Mo;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Mo||(Mo={}));var $a=function(e){Ka(t,e);function t(n,r,o){var i=e.call(this,n)||this;return i.code=r,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error);var uh=function(e){Ka(t,e);function t(n,r,o,i){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Mo.INVALID_VALUE,i)||this}return t}($a);var oE=function(e){Ka(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Mo.INVALID_VALUE,o)||this}return t}($a);var iE=function(e){Ka(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Mo.MISSING_VALUE,r)||this}return t}($a);var et;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(et||(et={}));function bI(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==et.literal||n.type!==et.literal?t.push(n):r.value+=n.value,t},[])}function CI(e){return typeof e=="function"}function qa(e,t,n,r,o,i,s){if(e.length===1&&ih(e[0]))return[{type:et.literal,value:e[0].value}];for(var a=[],l=0,u=e;l<u.length;l++){var c=u[l];if(ih(c)){a.push({type:et.literal,value:c.value});continue}if(eE(c)){typeof i=="number"&&a.push({type:et.literal,value:n.getNumberFormat(t).format(i)});continue}var m=c.value;if(!(o&&m in o))throw new iE(m,s);var d=o[m];if(J1(c)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?et.literal:et.object,value:d});continue}if(gd(c)){var f=typeof c.style=="string"?r.date[c.style]:Wa(c.style)?c.style.parsedOptions:void 0;a.push({type:et.literal,value:n.getDateTimeFormat(t,f).format(d)});continue}if(hd(c)){var f=typeof c.style=="string"?r.time[c.style]:Wa(c.style)?c.style.parsedOptions:r.time.medium;a.push({type:et.literal,value:n.getDateTimeFormat(t,f).format(d)});continue}if(md(c)){var f=typeof c.style=="string"?r.number[c.style]:wd(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(d=d*(f.scale||1)),a.push({type:et.literal,value:n.getNumberFormat(t,f).format(d)});continue}if(Sd(c)){var v=c.children,y=c.value,g=o[y];if(!CI(g))throw new oE(y,"function",s);var p=qa(v,t,n,r,o,i),h=g(p.map(function(T){return T.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(T){return{type:typeof T=="string"?et.literal:et.object,value:T}}))}if(yd(c)){var S=c.options[d]||c.options.other;if(!S)throw new uh(c.value,d,Object.keys(c.options),s);a.push.apply(a,qa(S.value,t,n,r,o));continue}if(vd(c)){var S=c.options["=".concat(d)];if(!S){if(!Intl.PluralRules)throw new $a(`Intl.PluralRules is not available in this environment.
13
+ `),ut}Xi(()=>{ao.current=void 0,Y.current=void 0,we.current=Qt});let Zt=(0,de.useMemo)(()=>de.default.createElement(g,Wn({},Qt,{ref:_})),[_,g,Qt]);return(0,de.useMemo)(()=>v?de.default.createElement(G.Provider,{value:hr},Zt):Zt,[G,Zt,hr])}let C=de.default.memo(x);if(C.WrappedComponent=g,C.displayName=x.displayName=h,l){let N=de.default.forwardRef(function(D,G){return de.default.createElement(C,Wn({},D,{reactReduxForwardedRef:G}))});return N.displayName=h,N.WrappedComponent=g,(0,Kg.default)(N,g)}return(0,Kg.default)(C,g)}}var $n=XL;var Da=w(H());function YL({store:e,context:t,children:n,serverState:r,stabilityCheck:o="once",noopCheck:i="once"}){let s=(0,Da.useMemo)(()=>{let u=Gc(e);return{store:e,subscription:u,getServerState:r?()=>r:void 0,stabilityCheck:o,noopCheck:i}},[e,r,o,i]),a=(0,Da.useMemo)(()=>e.getState(),[e]);Xi(()=>{let{subscription:u}=s;return u.onStateChange=u.notifyNestedSubs,u.trySubscribe(),a!==e.getState()&&u.notifyNestedSubs(),()=>{u.tryUnsubscribe(),u.onStateChange=void 0}},[s,a]);let l=t||Je;return Da.default.createElement(l.Provider,{value:s},n)}var Wg=YL;function Yc(e=Je){let t=e===Je?Tc:Oa(e);return function(){let{store:r}=t();return r}}var $g=Yc();function n1(e=Je){let t=e===Je?$g:Yc(e);return function(){return t().dispatch}}var X=n1();Lx(o1.useSyncExternalStoreWithSelector);t1(r1.useSyncExternalStore);Cx(Mg.unstable_batchedUpdates);var Fa=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Fa||{});var QL={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!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,floatingMenu:!1,enableSuggestionFeedback:!1,enableFeedbackForm:!1,adminUrl:void 0,productName:"Deepdesk"},i1=Q({name:"settings",initialState:QL,reducers:{set(e,t){Object.entries(t.payload).forEach(n=>{let[r,o]=n;typeof o!="undefined"&&(e[r]=o)})}}}),{set:Qc}=i1.actions,qg=e=>t=>t.settings[e],V=e=>M(qg(e)),s1=i1.reducer;var ZL={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},rt=e=>e.auth.isLoggedIn,a1=e=>e.auth.loginFetchState,l1=e=>e.auth.verifyFetchState,u1=e=>e.auth.showLoginOverlay,qn=K("auth/validate",(e,t)=>k(void 0,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),c1=K("auth/requestLogin",(n,r)=>k(void 0,[n,r],function*({email:e},t){let{deepdeskAPI:o}=t.extra;return o.requestLoginByEmail(e)})),Ha=K("auth/verifyLoginToken",(n,r)=>k(void 0,[n,r],function*({token:e},t){let{deepdeskAPI:o}=t.extra;return o.verifyLoginToken(e)})),d1=Q({name:"auth",initialState:ZL,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload}},extraReducers:e=>{e.addCase(qn.pending,t=>{t.loginFetchState="loading"}),e.addCase(qn.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(qn.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(Ha.pending,t=>{t.verifyFetchState="loading"}),e.addCase(Ha.rejected,t=>{t.verifyFetchState="error"}),e.addCase(Ha.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:Qi,setShowLoginOverlay:f1}=d1.actions,p1=d1.reducer;function Gn(){}Gn.prototype={diff:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=r.callback;typeof r=="function"&&(o=r,r={}),this.options=r;var i=this;function s(y){return o?(setTimeout(function(){o(void 0,y)},0),!0):y}t=this.castInput(t),n=this.castInput(n),t=this.removeEmpty(this.tokenize(t)),n=this.removeEmpty(this.tokenize(n));var a=n.length,l=t.length,u=1,c=a+l;r.maxEditLength&&(c=Math.min(c,r.maxEditLength));var m=[{newPos:-1,components:[]}],d=this.extractCommon(m[0],n,t,0);if(m[0].newPos+1>=a&&d+1>=l)return s([{value:this.join(n),count:n.length}]);function f(){for(var y=-1*u;y<=u;y+=2){var g=void 0,p=m[y-1],h=m[y+1],S=(h?h.newPos:0)-y;p&&(m[y-1]=void 0);var x=p&&p.newPos+1<a,T=h&&0<=S&&S<l;if(!x&&!T){m[y]=void 0;continue}if(!x||T&&p.newPos<h.newPos?(g=eI(h),i.pushComponent(g.components,void 0,!0)):(g=p,g.newPos++,i.pushComponent(g.components,!0,void 0)),S=i.extractCommon(g,n,t,y),g.newPos+1>=a&&S+1>=l)return s(JL(i,g.components,n,t,i.useLongestToken));m[y]=g}u++}if(o)(function y(){setTimeout(function(){if(u>c)return o();f()||y()},0)})();else for(;u<=c;){var v=f();if(v)return v}},pushComponent:function(t,n,r){var o=t[t.length-1];o&&o.added===n&&o.removed===r?t[t.length-1]={count:o.count+1,added:n,removed:r}:t.push({count:1,added:n,removed:r})},extractCommon:function(t,n,r,o){for(var i=n.length,s=r.length,a=t.newPos,l=a-o,u=0;a+1<i&&l+1<s&&this.equals(n[a+1],r[l+1]);)a++,l++,u++;return u&&t.components.push({count:u}),t.newPos=a,l},equals:function(t,n){return this.options.comparator?this.options.comparator(t,n):t===n||this.options.ignoreCase&&t.toLowerCase()===n.toLowerCase()},removeEmpty:function(t){for(var n=[],r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n},castInput:function(t){return t},tokenize:function(t){return t.split("")},join:function(t){return t.join("")}};function JL(e,t,n,r,o){for(var i=0,s=t.length,a=0,l=0;i<s;i++){var u=t[i];if(u.removed){if(u.value=e.join(r.slice(l,l+u.count)),l+=u.count,i&&t[i-1].added){var m=t[i-1];t[i-1]=t[i],t[i]=m}}else{if(!u.added&&o){var c=n.slice(a,a+u.count);c=c.map(function(f,v){var y=r[l+v];return y.length>f.length?y:f}),u.value=e.join(c)}else u.value=e.join(n.slice(a,a+u.count));a+=u.count,u.added||(l+=u.count)}}var d=t[s-1];return s>1&&typeof d.value=="string"&&(d.added||d.removed)&&e.equals("",d.value)&&(t[s-2].value+=d.value,t.pop()),t}function eI(e){return{newPos:e.newPos,components:e.components.slice(0)}}var tI=new Gn;function h1(e,t,n){return tI.diff(e,t,n)}var m1=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,g1=/\S/,y1=new Gn;y1.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!g1.test(e)&&!g1.test(t)};y1.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&m1.test(t[n])&&m1.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var v1=new Gn;v1.tokenize=function(e){var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var o=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),t.push(o))}return t};var nI=new Gn;nI.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var rI=new Gn;rI.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Zc(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Zc=function(t){return typeof t}:Zc=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zc(e)}var oI=Object.prototype.toString,Ua=new Gn;Ua.useLongestToken=!0;Ua.tokenize=v1.tokenize;Ua.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,o=r===void 0?function(i,s){return typeof s=="undefined"?n:s}:r;return typeof e=="string"?e:JSON.stringify(Gg(e,null,null,o),o," ")};Ua.equals=function(e,t){return Gn.prototype.equals.call(Ua,e.replace(/,([\r\n])/g,"$1"),t.replace(/,([\r\n])/g,"$1"))};function Gg(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o,e));var i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];var s;if(oI.call(e)==="[object Array]"){for(t.push(e),s=new Array(e.length),n.push(s),i=0;i<e.length;i+=1)s[i]=Gg(e[i],t,n,r,o);return t.pop(),n.pop(),s}if(e&&e.toJSON&&(e=e.toJSON()),Zc(e)==="object"&&e!==null){t.push(e),s={},n.push(s);var a=[],l;for(l in e)e.hasOwnProperty(l)&&a.push(l);for(a.sort(),i=0;i<a.length;i+=1)l=a[i],s[l]=Gg(e[l],t,n,r,l);t.pop(),n.pop()}else s=e;return s}var Xg=new Gn;Xg.tokenize=function(e){return e.slice()};Xg.join=Xg.removeEmpty=function(e){return e};function S1(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function $r(e,t,n=10){let r=typeof e,o=typeof t;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return r!==o?!1:e==null||r==="string"||r==="number"||r==="boolean"?e===t:Array.isArray(e)&&Array.isArray(t)?e.length!==t.length?!1:e.every((i,s)=>$r(i,t[s],n-1)):S1(e)&&S1(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(s=>$r(e[s],t[s],n-1)):!1}function iI(e){return Math.max(...e.map(t=>t.length))}function sI(e,t){let n=e.reduce((r,o)=>{if(o){let i=r[o]?r[o]+1:1;return O(P({},r),{[o]:i})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function w1(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<iI(r);o++){let i=sI(r.map(a=>a[o]),t),s=r.filter(a=>!i.includes(a[o]));if(s.length>=t)r=s;else return{text:r[0].slice(0,o).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var aI=2;function x1(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=w1(e,aI);return n&&n.text!==t?n:e[0]}var lI={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},z=lI;var E1={current:null,isSupported:null},fe=Re("resetConversation"),Zi=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.sessionId)||null},qr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},Ji=e=>e.conversation.isSupported,Yg=K("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.sessionId,e.options)}),Jc=K("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),ed=K("conversation/bySessionId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationBySessionId(e.sessionId,e.options)}),td=K("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=qr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),Qg=K("conversation/upsert",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationBySessionId(e.sessionId).catch(()=>null).then(r=>{if(!r)return n.createConversation(e);let{agentId:o,agentName:i,agentEmail:s,agentNickname:a,tags:l}=e;return n.updateConversation(r.id,{agentId:o,agentEmail:s,agentName:i,agentNickname:a,tags:l})})}),nd=K("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=qr(t.getState());if(!r)throw new Error("No current conversation to update messages");return n.postMessages(r,e.map(o=>P({},o)))}),uI=[Jc.rejected,ed.rejected,td.rejected,nd.rejected].map(e=>e==null?void 0:e.toString()),cI=Q({name:"conversation",initialState:E1,reducers:{},extraReducers:e=>{e.addCase(Yg.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(Jc.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(ed.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(Qg.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(td.fulfilled,(t,n)=>{var r,o;t.current=n.payload,t.isSupported=(o=(r=n.payload)==null?void 0:r.hasActiveProfile)!=null?o:null}).addCase(nd.fulfilled,(t,n)=>{t.current&&(t.current.messages=n.payload)}).addCase(fe,()=>E1).addMatcher(t=>uI.includes(t.type),(t,n)=>{var r;throw z.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),b1=cI.reducer;var Lo={text:"",html:null,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion: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 Zg(e){let{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}=e;return{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:i}}var rd=Re("input/replaceText"),Io=Re("input/sendMessage"),od=Re("input/applyImageSuggestion"),ot=Re("input/sendEvent"),C1=Q({name:"input",initialState:Lo,reducers:{setInput(e,t){var i,s;let{beforeInputChange:n}=e,{text:r,html:o}=t.payload;if(e.text=r,e.html=o||null,r==="")e.metrics=Lo.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:a,shiftKey:l,ctrlKey:u,metaKey:c,altKey:m}=n.keyDown;switch(a){case"Enter":l&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:d}=e,f=h1(n.text,d);n.text.length-d.length>1&&e.metrics.deletions.push(...f.filter(v=>v.removed).map(v=>v.value)),e.metrics.numCharsDeleted+=n.text.length-d.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(u||c)break;default:if(!u&&!c&&!m){e.metrics.numCharsTyped+=1;let d=((i=n.selection)==null?void 0:i.start)!==void 0&&((s=n.selection)==null?void 0:s.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;d&&d.length>0&&(e.metrics.numCharsDeleted+=d.length,e.metrics.deletions.push(d))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},setSelection(e,t){t.payload!==null&&($r(e.selection,t.payload)||(e.selection=t.payload))},commitSuggestion(e,t){let n=t.payload,{text:r,suggestion:{source:o,abVariant:i,abTestName:s,trainingJobs:a,sourceText:l,searchTerm:u,text:c},eventMetrics:{inputType:m},replace:d}=n,f=o==="search"||o==="personal-collection-search",v=r.slice(e.text.substring(0,e.selection.start).length);(f||d==="selection")&&(v=r),n.suggestion.source==="search-overlay"&&(v=c),e.metrics.textSuggestions.push({text:v,source:o,abVariant:i,abTestName:s,inputType:m,sourceText:l,trainingJobs:a||[],searchTerm:f?e.text:u}),e.textSuggestions=[],e.selectedSuggestionIndex=-1},offeredTextSuggestion(e,t){let{text:n,suggestion:{source:r}}=t.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:r})},registerKeyDown(e,t){let{key:n}=t.payload;["Control","Meta","Shift","Alt"].includes(n)||(e.beforeInputChange={text:e.text,selection:e.selection,keyDown:t.payload})},registerKeyUp(e,t){},registerCut(e,t){let{metrics:n}=e,r=t.payload;e.metrics=O(P({},e.metrics),{numCharsCut:n.numCharsCut+r.length,cuts:[...n.cuts,r]})},registerPaste(e,t){let{metrics:n}=e,{text:r,selectionText:o}=t.payload,i=n.numCharsDeleted+(o&&o.length?o.length:0),s=o&&o.length?[...n.deletions,o]:n.deletions;e.metrics=O(P({},e.metrics),{numCharsDeleted:i,deletions:s,numCharsPasted:n.numCharsPasted+r.length,numPaste:n.numPaste+1,pastes:[...n.pastes,r]})},selectNextTextSuggestion(e){let t=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<t-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},selectPreviousTextSuggestion(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},selectTextSuggestionByIndex(e,t){e.selectedSuggestionIndex=t.payload},setTextSuggestions(e,t){if(e.selectedSuggestionIndex=-1,e.textSuggestions=t.payload,t.payload.length===0){e.mixedSuggestion=null;return}let n=e.text.substring(0,e.selection.end),r=x1(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Lo.metrics}},extraReducers:e=>{e.addCase(fe,t=>{t.mixedSuggestion=Lo.mixedSuggestion,t.textSuggestions=Lo.textSuggestions,t.selectedSuggestionIndex=Lo.selectedSuggestionIndex,t.metrics=Lo.metrics})}}),es=e=>e.input.text.substring(0,e.input.selection.end),dI=e=>e.input.selection,ts=e=>{let{mixedSuggestion:t,selectedSuggestionIndex:n,textSuggestions:r}=e.input;return n>-1?r[n]:t},T1=()=>M(dI),{commitSuggestion:rn,offeredTextSuggestion:k1,registerCut:P1,registerKeyDown:R1,registerKeyUp:A1,registerPaste:L1,selectNextTextSuggestion:I1,selectPreviousTextSuggestion:N1,selectTextSuggestionByIndex:id,setInput:sd,setMetrics:O1,setSelection:ad,setTextSuggestions:Xn,resetMetrics:M1}=C1.actions,_1=C1.reducer;function fI(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function re(e){return Array.isArray(e)?e.map(re):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>O(P({},t),{[fI(n)]:re(e[n])}),{}):e}function Jg(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ne(e){return Array.isArray(e)?e.map(Ne):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>O(P({},t),{[Jg(n)]:Ne(e[n])}),{}):e}var pI={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,fetchState:"idle"},Ba=e=>{var t,n,r;return{timezone:((t=e.info.visitorInfo)==null?void 0:t.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=e.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((r=e.info.visitorInfo)==null?void 0:r.visitorName)||""}},za=K("info/setAgentInfo",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;if(!e.agentId&&!e.agentNickname)throw new Error("At least provide agentId or agentNickname");let r=yield n.client.get("/apis/admin/session/me/",{version:null}),o={};return r.external_id||(o.external_id=e.agentId),r.nickname||(o.nickname=e.agentNickname),!o.external_id&&!o.nickname?re(r):(yield n.client.patch("/apis/admin/session/me/",o,{version:null}),re(r))})),eh=K("info/setAgentSettings",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.client.get("/apis/admin/session/me/",{version:null}),o=P(P({},typeof r.ui_config=="object"?r.ui_config:{}),e);return yield n.client.patch("/apis/admin/session/me/",{ui_config:o}),o})),th=K("info/getAgentSettings",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.client.get("/apis/admin/session/me/",{version:null})).ui_config})),D1=e=>e.info.agentInfo,F1=e=>e.info.customData,H1=Q({name:"info",initialState:pI,reducers:{setVisitorInfo(e,t){e.visitorInfo=P(P({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload}},extraReducers:e=>{e.addCase(za.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=P(P({},t.agentInfo),n.meta.arg)}).addCase(za.rejected,t=>{t.fetchState="error"}).addCase(za.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=O(P(P({},t.agentInfo),n.meta.arg),{agentDefaultLocale:n.payload.defaultLocale,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""})}).addCase(eh.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(th.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(fe,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:U1,setCustomData:z1}=H1.actions,B1=H1.reducer;var ld={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},j1=e=>e.search.isOpen,V1=e=>e.search.page,K1=e=>e.search.list,W1=e=>e.search.aggregates;function $1(e,t=n=>n){return n=>n.search.list.filter(r=>r.type===e).map(t)}var No=K("search/getAll",(e,t)=>k(void 0,null,function*(){var a;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(a=r.conversation.current)==null?void 0:a.profileCode;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:s}=yield n.search({profile:o,query:e.query,tags:e.tags,size:e.size,current:e.current,filters:{type:e.type},params:Ba(r)});return{results:i.map(l=>O(P({},l),{source:`search-${l.type.toLowerCase()}`,searchTerm:e.query})),aggregates:s}})),q1=Q({name:"search",initialState:ld,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=ld.fetchState,e.list=ld.list}},extraReducers:e=>{e.addCase(No.pending,t=>{t.fetchState="loading"}).addCase(No.rejected,(t,n)=>{t.fetchState="error",z.error(n.error)}).addCase(No.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(fe,()=>ld)}}),{resetSearch:ud,setIsOpen:Ct,setPage:on}=q1.actions,G1=q1.reducer;var nh="SetCues",ns="ShowLoginOverlay",ja="UserLoggedIn",mI="UserLoggedOut",Gr="ApplySuggestion",rh="ApplyImageSuggestion",gI="ShowCommandPalette",hI=e=>({[nh]:t=>{e.dispatch(O(P({},t),{isBroadcasted:!0}))},[gI]:t=>{e.dispatch(Ct(t.isOpen)),t.page&&e.dispatch(on(t.page))},[ns]:t=>{e.dispatch(f1(t))},[ja]:()=>{e.dispatch(qn())},[mI]:()=>{e.dispatch(qn())},[rh]:t=>{e.dispatch(od({suggestion:t.suggestion}))},[Gr]:t=>{e.dispatch(rn(O(P({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),X1=hI;var Va=w(H()),Q1=w(b()),Y1=Va.default.createContext(null),Oo=({broadcastEvents:e,children:t})=>{let n=Va.default.useMemo(()=>e,[]);return(0,Q1.jsx)(Y1.Provider,{value:n,children:t})},Wt=()=>{let e=(0,Va.useContext)(Y1);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var kd=w(ie()),an=w(H());var bd=w(H());var oh=function(e,t){return oh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},oh(e,t)};function Ka(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");oh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Tt=function(){return Tt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Tt.apply(this,arguments)};function Z1(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function cd(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var dd;(function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(dd||(dd={}));var fd=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var sn;(function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"})(sn||(sn={}));var pd;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(pd||(pd={}));function ih(e){return e.type===sn.literal}function J1(e){return e.type===sn.argument}function md(e){return e.type===sn.number}function gd(e){return e.type===sn.date}function hd(e){return e.type===sn.time}function yd(e){return e.type===sn.select}function vd(e){return e.type===sn.plural}function eE(e){return e.type===sn.pound}function Sd(e){return e.type===sn.tag}function wd(e){return!!(e&&typeof e=="object"&&e.type===pd.number)}function Wa(e){return!!(e&&typeof e=="object"&&e.type===pd.dateTime)}function sh(e){e.forEach(function(t){if(delete t.location,yd(t)||vd(t))for(var n in t.options)delete t.options[n].location,sh(t.options[n].value);else md(t)&&wd(t.style)||(gd(t)||hd(t))&&Wa(t.style)?delete t.style.location:Sd(t)&&sh(t.children)})}function tE(e,t){t===void 0&&(t={}),t=Tt({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new fd(e,t).parse();if(n.err){var r=SyntaxError(dd[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||sh(n.val),n.val}function xd(e,t){var n=t&&t.cache?t.cache:EI,r=t&&t.serializer?t.serializer:xI,o=t&&t.strategy?t.strategy:vI;return o(e,{cache:n,serializer:r})}function yI(e){return e==null||typeof e=="number"||typeof e=="boolean"}function nE(e,t,n,r){var o=yI(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function rE(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.apply(this,r),t.set(o,i)),i}function ah(e,t,n,r,o){return n.bind(t,e,r,o)}function vI(e,t){var n=e.length===1?nE:rE;return ah(e,this,n,t.cache.create(),t.serializer)}function SI(e,t){return ah(e,this,rE,t.cache.create(),t.serializer)}function wI(e,t){return ah(e,this,nE,t.cache.create(),t.serializer)}var xI=function(){return JSON.stringify(arguments)};function lh(){this.cache=Object.create(null)}lh.prototype.get=function(e){return this.cache[e]};lh.prototype.set=function(e,t){this.cache[e]=t};var EI={create:function(){return new lh}},Ed={variadic:SI,monadic:wI};var Mo;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Mo||(Mo={}));var $a=function(e){Ka(t,e);function t(n,r,o){var i=e.call(this,n)||this;return i.code=r,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error);var uh=function(e){Ka(t,e);function t(n,r,o,i){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Mo.INVALID_VALUE,i)||this}return t}($a);var oE=function(e){Ka(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Mo.INVALID_VALUE,o)||this}return t}($a);var iE=function(e){Ka(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),Mo.MISSING_VALUE,r)||this}return t}($a);var et;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(et||(et={}));function bI(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==et.literal||n.type!==et.literal?t.push(n):r.value+=n.value,t},[])}function CI(e){return typeof e=="function"}function qa(e,t,n,r,o,i,s){if(e.length===1&&ih(e[0]))return[{type:et.literal,value:e[0].value}];for(var a=[],l=0,u=e;l<u.length;l++){var c=u[l];if(ih(c)){a.push({type:et.literal,value:c.value});continue}if(eE(c)){typeof i=="number"&&a.push({type:et.literal,value:n.getNumberFormat(t).format(i)});continue}var m=c.value;if(!(o&&m in o))throw new iE(m,s);var d=o[m];if(J1(c)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?et.literal:et.object,value:d});continue}if(gd(c)){var f=typeof c.style=="string"?r.date[c.style]:Wa(c.style)?c.style.parsedOptions:void 0;a.push({type:et.literal,value:n.getDateTimeFormat(t,f).format(d)});continue}if(hd(c)){var f=typeof c.style=="string"?r.time[c.style]:Wa(c.style)?c.style.parsedOptions:r.time.medium;a.push({type:et.literal,value:n.getDateTimeFormat(t,f).format(d)});continue}if(md(c)){var f=typeof c.style=="string"?r.number[c.style]:wd(c.style)?c.style.parsedOptions:void 0;f&&f.scale&&(d=d*(f.scale||1)),a.push({type:et.literal,value:n.getNumberFormat(t,f).format(d)});continue}if(Sd(c)){var v=c.children,y=c.value,g=o[y];if(!CI(g))throw new oE(y,"function",s);var p=qa(v,t,n,r,o,i),h=g(p.map(function(T){return T.value}));Array.isArray(h)||(h=[h]),a.push.apply(a,h.map(function(T){return{type:typeof T=="string"?et.literal:et.object,value:T}}))}if(yd(c)){var S=c.options[d]||c.options.other;if(!S)throw new uh(c.value,d,Object.keys(c.options),s);a.push.apply(a,qa(S.value,t,n,r,o));continue}if(vd(c)){var S=c.options["=".concat(d)];if(!S){if(!Intl.PluralRules)throw new $a(`Intl.PluralRules is not available in this environment.
14
14
  Try polyfilling it using "@formatjs/intl-pluralrules"
15
15
  `,Mo.MISSING_INTL_API,s);var x=n.getPluralRules(t,{type:c.pluralType}).select(d-(c.offset||0));S=c.options[x]||c.options.other}if(!S)throw new uh(c.value,d,Object.keys(c.options),s);a.push.apply(a,qa(S.value,t,n,r,o,d-(c.offset||0)));continue}}return bI(a)}function TI(e,t){return t?Tt(Tt(Tt({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=Tt(Tt({},e[r]),t[r]||{}),n},{})):e}function kI(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=TI(e[r],t[r]),n},Tt({},e)):e}function ch(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function PI(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:xd(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,cd([void 0],n,!1)))},{cache:ch(e.number),strategy:Ed.variadic}),getDateTimeFormat:xd(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,cd([void 0],n,!1)))},{cache:ch(e.dateTime),strategy:Ed.variadic}),getPluralRules:xd(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,cd([void 0],n,!1)))},{cache:ch(e.pluralRules),strategy:Ed.variadic})}}var sE=function(){function e(t,n,r,o){n===void 0&&(n=e.defaultLocale);var i=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(u){var c=i.formatToParts(u);if(c.length===1)return c[0].value;var m=c.reduce(function(d,f){return!d.length||f.type!==et.literal||typeof d[d.length-1]!="string"?d.push(f.value):d[d.length-1]+=f.value,d},[]);return m.length<=1?m[0]||"":m},this.formatToParts=function(u){return qa(i.ast,i.locales,i.formatters,i.formats,u,void 0,i.message)},this.resolvedOptions=function(){var u;return{locale:((u=i.resolvedLocale)===null||u===void 0?void 0:u.toString())||Intl.NumberFormat.supportedLocalesOf(i.locales)[0]}},this.getAst=function(){return i.ast},this.locales=n,this.resolvedLocale=e.resolveLocale(n),typeof t=="string"){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var s=o||{},a=s.formatters,l=Z1(s,["formatters"]);this.ast=e.__parse(t,Tt(Tt({},l),{locale:this.resolvedLocale}))}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=kI(e.formats,r),this.formatters=o&&o.formatters||PI(this.formatterCache)}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.resolveLocale=function(t){if(typeof Intl.Locale!="undefined"){var n=Intl.NumberFormat.supportedLocalesOf(t);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=tE,e.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"}}},e}();function RI(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var AI="dummy",dh=(0,bd.createContext)(null);function q(e){var r;let t=(0,bd.useContext)(dh);if(!t)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=(r=e[t])!=null?r:{};return(o,i)=>{let s=RI(n,o);return s?new sE(s).format(i):(t!==AI&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}var Cd=w(H());var aE={root:"dd-tvkOF",content:"dd-eXA1D"};var fh=w(b()),LI=({isOpen:e,autoFocus:t,children:n,onClose:r,onBack:o,onKeyDown:i,overlayAriaLabel:s,contentAriaLabel:a})=>{let l=(0,Cd.useRef)(null),u=A("Dialog",aE),c=d=>{if(d.key==="Escape"){d.preventDefault(),d.stopPropagation(),o();return}i&&i(d)},m=d=>{d.target===l.current&&e&&r()};return(0,Cd.useEffect)(()=>{var d,f;!l.current||!e||!t||(f=(d=l.current)==null?void 0:d.querySelector("input, textarea"))==null||f.focus()},[e,t,l]),e?(0,fh.jsx)("div",{role:"dialog","data-testid":"dialog",className:u.root,"aria-label":s,ref:l,onKeyDown:c,onMouseDown:m,children:(0,fh.jsx)("div",{"data-testid":"dialog-content",className:u.content,"aria-label":a,children:n})}):null},Td=LI;var uE=w(ie());var lE={root:"dd-ranhW"};var cE=w(b()),II=r=>{var o=r,{className:e,value:t}=o,n=te(o,["className","value"]);let i=A("TextInput",lE);return(0,cE.jsx)("input",P({className:(0,uE.default)(e,i.root),type:"text",value:t},n))},Ga=II;var ph={};$e(ph,{enUS:()=>NI,nlNL:()=>OI});var NI={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"}]},OI={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 dE={root:"dd-lWxnE",anchorButton:"dd-TZ4in",errorMessage:"dd-fIsPg",title:"dd-pGhJx",subtitle:"dd-f5l29",text:"dd-iamoD",input:"dd-uhQZ3",actions:"dd-lubvx",button:"dd-CJsNI",primaryButton:"dd-MWBfl"};var Ae=w(b());var MI=e=>{try{let t=new URL(e);return new URLSearchParams(t.search).get("token")||void 0}catch(t){return e}},_I=({agentEmail:e,isOpen:t,origin:n="",onSuccess:r,onDismiss:o})=>{let i=q(ph),s=A("LoginTokenDialog",dE),a=M(l1),l=X(),u=V("productName"),[c,m]=(0,an.useState)(e||""),[d,f]=(0,an.useState)(0),[v,y]=(0,an.useState)(""),g=(0,an.useCallback)(x=>k(void 0,null,function*(){x.preventDefault(),l(c1({email:c})),f(1)}),[n,c]),p=()=>{y(""),f(0)},h=(0,an.useCallback)(x=>k(void 0,null,function*(){x.preventDefault();let T=MI(x.target.elements.token.value);if(!T){y(i("verifyCodeError",{login:S}));return}l(Ha({token:T}))}),[n]),S=(0,an.useMemo)(()=>x=>(0,Ae.jsx)("button",{type:"button","data-testid":"login-token-dialog-back-button",className:s.anchorButton,onClick:p,children:x},"back-button"),[]);return(0,an.useEffect)(()=>{a==="error"&&y(i("verifyCodeError",{login:S})),a==="done"&&r()},[a]),(0,Ae.jsx)(Td,{autoFocus:!0,isOpen:t,contentAriaLabel:i("promptTitle",{productName:u}),overlayAriaLabel:i("promptTitle",{productName:u}),onClose:o,onBack:o,children:(0,Ae.jsxs)("div",{className:s.root,children:[(0,Ae.jsx)("h1",{className:s.title,children:i("promptTitle",{productName:u})}),d===0&&(0,Ae.jsxs)("form",{onSubmit:g,children:[(0,Ae.jsx)("h2",{className:s.subtitle,children:i("requestCodeTitle")}),(0,Ae.jsx)("p",{className:s.text,children:i("requestCodeBody",{productName:u})}),(0,Ae.jsx)(Ga,{className:s.input,name:"email",placeholder:i("requestCodeInputPlaceholder"),value:c,onChange:x=>m(x.target.value)}),(0,Ae.jsx)("div",{className:s.actions,children:(0,Ae.jsx)("button",{type:"submit",className:(0,kd.default)(s.button,s.primaryButton),children:i("requestCodeSubmitLabel")})})]}),d===1&&(0,Ae.jsxs)("form",{onSubmit:h,children:[(0,Ae.jsx)("h2",{className:s.subtitle,children:i("verifyCodeTitle")}),(0,Ae.jsx)("p",{className:s.text,children:i("verifyCodeBody")}),(0,Ae.jsx)(Ga,{className:s.input,name:"token",placeholder:i("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),v&&(0,Ae.jsx)("div",{className:s.errorMessage,children:v}),(0,Ae.jsxs)("div",{className:s.actions,children:[(0,Ae.jsx)("button",{type:"button",className:(0,kd.default)(s.button),onClick:p,children:i("back")}),(0,Ae.jsx)("button",{type:"submit",className:(0,kd.default)(s.button,s.primaryButton),disabled:["loading","done"].includes(a),children:i("verifyCodeSubmitLabel")})]})]})]})})},fE=_I;var mE=w(b()),DI=()=>{let e=M(u1),t=M(D1),n=V("adminUrl"),r=Wt(),o=()=>r.send(ns,!1),i=()=>{r.send(ns,!1),r.send(ja)};return(0,mE.jsx)(fE,{isOpen:e,agentEmail:t==null?void 0:t.agentEmail,origin:n,onDismiss:o,onSuccess:i})},pE=DI;var Ab=w(hh()),Pt=w(H());var eN={data:null,fetchState:"idle"},vE=e=>e.contentTypes.data,Xa=K("contentTypes/getContentTypes",(e,t)=>k(void 0,null,function*(){return t.extra.deepdeskAPI.getContentTypes()})),tN=Q({name:"contentTypes",initialState:eN,reducers:{},extraReducers:e=>{e.addCase(Xa.pending,t=>{t.fetchState="loading"}).addCase(Xa.rejected,t=>{t.fetchState="error"}).addCase(Xa.fulfilled,(t,n)=>{t.fetchState="done",t.data=n.payload})}}),SE=tN.reducer;function Yn(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),t.remove()}var er=w(H());var wE=w(H()),Pd=w(ie());var kt={root:"dd-U2SX4",list:"dd-cYTlj",listWrapper:"dd-GLQFR",listHorizontal:"dd-x-knl",page:"dd-1F4vk",search:"dd-nvbxc",pageNav:"dd-sRUuT",pageTitle:"dd-t-MKS",pageBackButton:"dd-cjptm",listHeader:"dd-Fg666",listHeading:"dd-w-xhJ",listMoreButton:"dd--mKep",listItem:"dd-wpvuA",listItemContent:"dd-V-mKo",listItemText:"dd-ukCHL",listItemDescription:"dd-sSyu4",listItemActions:"dd-xelho",truncate:"dd-IlopJ",lineClamp:"dd-Twaca",listItemTitle:"dd-lMGHq",listItemAction:"dd-xPLAs",listItemPrimaryAction:"dd-LdJ8w",listItemSelected:"dd-jFX0Y",sources:"dd-pZx4v",sourcesTitle:"dd-phYVd",source:"dd-DaR6h",sourceShowMore:"dd-M1-8j",icon:"dd-m6yxD",searchIcon:"dd-0AU-O",searchInputWrapper:"dd-DUFcE",searchInput:"dd-ukrlD",select:"dd--Tifv",selectType:"dd-IkZb2",selectWrapper:"dd-J14mx",image:"dd-RQgsB",imageSrc:"dd-jxh8F",imageSrcHidden:"dd-e20Jk",imageSrcStatus:"dd-j50Tt",imageTitle:"dd-qCjfW",actions:"dd-3mfWc",actionsWrapper:"dd-TjDyI",actionsBar:"dd-LiA35",actionButton:"dd-4wk0u",hasShortKeys:"dd-XilV-",actionShortcut:"dd-s4Mla",actionShortcutFixKerning:"dd-lyh5e"};var Qn={};$e(Qn,{enUS:()=>nN,nlNL:()=>rN});var nN={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}],loading:[{type:0,value:"Loading..."}],imageError:[{type:0,value:"Could not load image"}],showAll:[{type:0,value:"Show more"}],sources:[{type:0,value:"Sources"}],showMore:[{type:0,value:"Show "},{type:1,value:"amount"},{type:0,value:" more"}]},rN={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}],loading:[{type:0,value:"Laden..."}],imageError:[{type:0,value:"Kan afbeelding niet laden"}],showAll:[{type:0,value:"Toon meer"}],sources:[{type:0,value:"Bronnen"}],showMore:[{type:0,value:"Toon "},{type:1,value:"amount"},{type:0,value:" meer"}]};var Xr=w(b()),oN=({src:e,title:t})=>{let n=A("CommandPalette",kt),[r,o]=(0,wE.useState)("loading"),i=q(Qn);return(0,Xr.jsxs)("div",{className:n.image,children:[(0,Xr.jsx)("img",{src:e,alt:t,onLoad:()=>o("done"),onError:()=>o("error"),className:(0,Pd.default)(n.imageSrc,{[n.imageSrcHidden]:["loading","error"].includes(r)})}),r==="loading"&&(0,Xr.jsx)("span",{className:(0,Pd.default)(n.imageSrc,n.imageSrcStatus),children:i("loading")}),r==="error"&&(0,Xr.jsx)("span",{className:(0,Pd.default)(n.imageSrc,n.imageSrcStatus),children:(0,Xr.jsx)(Gl,{})}),t&&(0,Xr.jsx)("span",{className:n.imageTitle,children:t})]})},xE=oN;var EE=w(H()),bE=w(ie());var _o=w(b());function yh({children:e,heading:t,orientation:n,hasMore:r,onShowAll:o}){let i=q(Qn),s=A("CommandPalette",kt);return EE.default.Children.count(e)===0?null:(0,_o.jsxs)("div",{"data-testid":"commandpalette-list",className:s.list,children:[(t||r)&&(0,_o.jsxs)("div",{className:s.listHeader,children:[t&&(0,_o.jsx)("h4",{className:s.listHeading,children:t}),r&&o&&(0,_o.jsx)("button",{onClick:o,className:s.listMoreButton,type:"button",children:i("showAll")})]}),(0,_o.jsx)("div",{className:(0,bE.default)(s.listWrapper,n==="horizontal"&&s.listHorizontal),children:e})]})}var is=w(ie());var Rd=w(H());function Ya(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=1,Sh=2,wh=4,Oe=8,Ad=16,Qa=32,ln=64,vh={a:{content:le|Oe,self:!1,type:le|Oe|Qa|ln},address:{invalid:["h1","h2","h3","h4","h5","h6","address","article","aside","section","div","header","footer"],self:!1},audio:{children:["track","source"]},br:{type:le|Oe,void:!0},body:{content:le|Sh|wh|Oe|Ad|Qa|ln},button:{content:Oe,type:le|Oe|Qa|ln},caption:{content:le,parent:["table"]},col:{parent:["colgroup"],void:!0},colgroup:{children:["col"],parent:["table"]},details:{children:["summary"],type:le|Qa|ln},dd:{content:le,parent:["dl"]},dl:{children:["dt","dd"],type:le},dt:{content:le,invalid:["footer","header"],parent:["dl"]},figcaption:{content:le,parent:["figure"]},footer:{invalid:["footer","header"]},header:{invalid:["footer","header"]},hr:{type:le,void:!0},img:{void:!0},li:{content:le,parent:["ul","ol","menu"]},main:{self:!1},ol:{children:["li"],type:le},picture:{children:["source","img"],type:le|Oe|Ad},rb:{parent:["ruby","rtc"]},rp:{parent:["ruby","rtc"]},rt:{content:Oe,parent:["ruby","rtc"]},rtc:{content:Oe,parent:["ruby"]},ruby:{children:["rb","rp","rt","rtc"]},source:{parent:["audio","video","picture"],void:!0},summary:{content:Oe,parent:["details"]},table:{children:["caption","colgroup","thead","tbody","tfoot","tr"],type:le},tbody:{parent:["table"],children:["tr"]},td:{content:le,parent:["tr"]},tfoot:{parent:["table"],children:["tr"]},th:{content:le,parent:["tr"]},thead:{parent:["table"],children:["tr"]},tr:{parent:["table","tbody","thead","tfoot"],children:["th","td"]},track:{parent:["audio","video"],void:!0},ul:{children:["li"],type:le},video:{children:["track","source"]},wbr:{type:le|Oe,void:!0}};function Fo(e){return t=>{vh[t]=P(P({},e),vh[t])}}["address","main","div","figure","p","pre"].forEach(Fo({content:le,type:le|ln}));["abbr","b","bdi","bdo","cite","code","data","dfn","em","i","kbd","mark","q","ruby","samp","strong","sub","sup","time","u","var"].forEach(Fo({content:Oe,type:le|Oe|ln}));["p","pre"].forEach(Fo({content:Oe,type:le|ln}));["s","small","span","del","ins"].forEach(Fo({content:Oe,type:le|Oe}));["article","aside","footer","header","nav","section","blockquote"].forEach(Fo({content:le,type:le|Sh|ln}));["h1","h2","h3","h4","h5","h6"].forEach(Fo({content:Oe,type:le|wh|ln}));["audio","canvas","iframe","img","video"].forEach(Fo({type:le|Oe|Ad|ln}));var Ja=Object.freeze(vh),xh=["applet","base","body","command","embed","frame","frameset","head","html","link","meta","noscript","object","script","style","title"],Eh=Object.keys(Ja).filter(e=>e!=="canvas"&&e!=="iframe"),pe=1,bh=2,Do=3,Yr=4,Id=5,Nd=Object.freeze({alt:pe,cite:pe,class:pe,colspan:Do,controls:Yr,datetime:pe,default:Yr,disabled:Yr,dir:pe,height:pe,href:pe,id:pe,kind:pe,label:pe,lang:pe,loading:pe,loop:Yr,media:pe,muted:Yr,poster:pe,rel:pe,role:pe,rowspan:Do,scope:pe,sizes:pe,span:Do,start:Do,style:Id,src:pe,srclang:pe,srcset:pe,tabindex:pe,target:pe,title:pe,type:pe,width:pe}),Ch=Object.freeze({class:"className",colspan:"colSpan",datetime:"dateTime",rowspan:"rowSpan",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex"});function Ld(){return Ld=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ld.apply(this,arguments)}function Od({attributes:e={},className:t,children:n=null,selfClose:r=!1,tagName:o}){let i=o;return r?Rd.default.createElement(i,Ld({className:t},e)):Rd.default.createElement(i,Ld({className:t},e),n)}var Za=class{attribute(t,n){return n}node(t,n){return n}};function CE(e,t,n,r=!1){let o=e.match(t instanceof RegExp?t:new RegExp(t,"i"));return o?O(P({match:o[0],void:r},n(o)),{index:o.index,length:o[0].length,valid:!0}):null}var Zn=class{constructor(t,n,r){Ya(this,"greedy",!1),Ya(this,"options",void 0),Ya(this,"propName",void 0),Ya(this,"inverseName",void 0),Ya(this,"factory",void 0),this.options=P({},n),this.propName=t,this.inverseName=`no${t.charAt(0).toUpperCase()+t.slice(1)}`,this.factory=r!=null?r:null}createElement(t,n){return this.factory?Rd.default.createElement(this.factory,n,t):this.replaceWith(t,n)}doMatch(t,n,r,o=!1){return CE(t,n,r,o)}onBeforeParse(t,n){return t}onAfterParse(t,n){return t}};var Ho=w(H()),RE=w(kE());function Jn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var aN=/(url|image|image-set)\(/i,Th=class extends Za{attribute(t,n){return t==="style"&&Object.keys(n).forEach(r=>{String(n[r]).match(aN)&&delete n[r]}),n}},PE=1,lN=3,uN=/^<(!doctype|(html|head|body)(\s|>))/i,cN=/^(aria-|data-|\w+:)/iu,dN=/{{{(\w+)\/?}}}/;function fN(){if(!(typeof window=="undefined"||typeof document=="undefined"))return document.implementation.createHTMLDocument("Interweave")}var Md=class{constructor(t,n={},r=[],o=[]){var i;Jn(this,"allowed",void 0),Jn(this,"banned",void 0),Jn(this,"blocked",void 0),Jn(this,"container",void 0),Jn(this,"content",[]),Jn(this,"props",void 0),Jn(this,"matchers",void 0),Jn(this,"filters",void 0),Jn(this,"keyIndex",void 0),this.props=n,this.matchers=r,this.filters=[...o,new Th],this.keyIndex=-1,this.container=this.createContainer(t||""),this.allowed=new Set((i=n.allowList)!==null&&i!==void 0?i:Eh),this.banned=new Set(xh),this.blocked=new Set(n.blockList)}applyAttributeFilters(t,n){return this.filters.reduce((r,o)=>r!==null&&typeof o.attribute=="function"?o.attribute(t,r):r,n)}applyNodeFilters(t,n){return this.filters.reduce((r,o)=>r!==null&&typeof o.node=="function"?o.node(t,r):r,n)}applyMatchers(t,n){let r={},{props:o}=this,i=t,s=0,a=null;return this.matchers.forEach(l=>{let u=l.asTag().toLowerCase(),c=this.getTagConfig(u);if(o[l.inverseName]||!this.isTagAllowed(u)||!this.canRenderChild(n,c))return;let m="";for(;i&&(a=l.match(i));){let d=a,{index:f,length:v,match:y,valid:g,void:p}=d,h=te(d,["index","length","match","valid","void"]),S=l.propName+String(s);f>0&&(m+=i.slice(0,f)),g?(m+=p?`{{{${S}/}}}`:`{{{${S}}}}${y}{{{/${S}}}}`,this.keyIndex+=1,s+=1,r[S]={children:y,matcher:l,props:O(P(P({},o),h),{key:this.keyIndex})}):m+=y,l.greedy?(i=m+i.slice(f+v),m=""):i=i.slice(f+(v||y.length))}l.greedy||(i=m+i)}),s===0?t:this.replaceTokens(i,r)}canRenderChild(t,n){return!t.tagName||!n.tagName||t.void?!1:t.children.length>0?t.children.includes(n.tagName):t.invalid.length>0&&t.invalid.includes(n.tagName)?!1:n.parent.length>0?n.parent.includes(t.tagName):!t.self&&t.tagName===n.tagName?!1:!!(t&&t.content&n.type)}convertLineBreaks(t){let{noHtml:n,disableLineBreaks:r}=this.props;if(n||r||t.match(/<((?:\/[ a-z]+)|(?:[ a-z]+\/))>/gi))return t;let o=t.replace(/\r\n/g,`
16
16
  `);return o=o.replace(/\n{3,}/g,`
@@ -20,11 +20,11 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
20
20
  c-17.9,17.9-27.3,40.1-27.3,65.7C163.4,163,163.4,233,163.4,233z M465.5,267.9V477c0,9.4-3.4,17.9-10.2,24.7
21
21
  c-6.8,6.8-15.4,10.2-24.7,10.2h-349c-9.4,0-17.9-3.4-24.7-10.2c-6.8-6.8-10.2-15.4-10.2-24.7V267.9c0-9.4,3.4-17.9,10.2-24.7
22
22
  c6.8-6.8,15.4-10.2,24.7-10.2h11.9v-70c0-44.4,16.2-82.8,47.8-115.2S212.1,0,256.4,0s82.8,16.2,115.2,47.8
23
- c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Bh=w(b()),lO={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Mb=({className:e,color:t})=>(0,Bh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Bh.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:lO[t||"pink"]})});var _b={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var jh={};$e(jh,{enUS:()=>uO,nlNL:()=>cO});var uO={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},cO={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Ko=w(b()),Fb=({onLogIn:e})=>{let t=q(jh),n=V("floatingMenu"),r=V("productName"),o=X(),i=M(rt),s=A("FloatingMenu",_b);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Ct(!0)):e()};return(0,Ko.jsxs)("button",{className:(0,Db.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Ko.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Ko.jsxs)("div",{className:s.icon,children:[(0,Ko.jsx)(Mb,{className:s.logo,color:"pink"}),i===!1&&(0,Ko.jsx)(Ob,{className:s.lock})]})]})};var Yd=w(H());var Hb=w(H());function Zr(e){(0,Hb.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function Wo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function Rn(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var dO={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},$d=({ui:e})=>e.overlayCollapsed,Ub=Q({name:"ui",initialState:dO,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:dl,setInputFocus:qd,setOverlayCollapsed:Jr,setOpenOverlayWhenTyping:zb,setOverlayCollapsedUserOverwrite:Bb}=Ub.actions,jb=Ub.reducer;var Gd=w(H());var ps=w(H());var Vb=w(H());function Kb(e,t,n){(0,Vb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var Wb={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var $o=w(b()),pO=["search","personal-collection-search","search-autocomplete"];function mO(e,t,n,r={}){var i;let o="";return pO.includes(t)?o=AE(kh(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=kh(e,n,r),r.placeholders===!0&&(o=LE(o)),o}var gO=()=>{},hO=({selected:e,suggestion:t})=>{let n=V("inlineSuggestions"),r=M(es),o=V("enableSuggestionFeedback"),i=M(c=>c.input.text),s=X(),a=A("TextSuggestion",Wb),l=(0,ps.useRef)(null);(0,ps.useEffect)(()=>{let c=setTimeout(()=>{s(k1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Kb(l,"click",()=>{s(rn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,ps.useMemo)(()=>mO(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,$o.jsxs)("div",{className:a.root,children:[(0,$o.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:gO,children:(0,$o.jsx)(rs,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),e&&o&&(0,$o.jsx)("div",{className:a.actions,children:(0,$o.jsx)(Kd,{source:"overlay",context:i,suggestion:t})})]})},$b=hO;var Vh=w(b()),yO=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Gd.useMemo)(()=>{let o=e.map((i,s)=>(0,Vh.jsx)($b,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Vh.jsx)(Gd.Fragment,{children:r})},Xd=yO;var qb={root:"dd-PfvRI",paper:"dd-HYlyY"};var fl=w(b()),vO=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Yd.useRef)(null),r=A("InlineSuggestionsOverlay",qb),o=M(Rn),i=X(),s=M(rt),a=M(Ji),l=M($d),u=V("showTextSuggestions");return Zr(()=>{setTimeout(()=>{i(Jr({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Yd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let m=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-m.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,fl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,fl.jsx)("div",{ref:n,className:r.paper,children:(0,fl.jsx)(mt,{children:(0,fl.jsx)(Xd,{suggestions:e,selectedIndex:t})})})})},SO=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),Gb=$n(SO)(vO);var pl=w(b()),wO=({children:e})=>{let n=V("locale").replace("-","");return(0,pl.jsx)(dh.Provider,{value:n,children:e})},xO=({store:e,customStyles:t={},children:n})=>(0,pl.jsx)(Wg,{store:e,children:(0,pl.jsx)(wO,{children:(0,pl.jsx)(Ls.Provider,{value:t,children:n})})}),qo=xO;var Zd=w(ie()),ms=w(H());var Xb=w(H());function Yb(e,t){let[n,r]=(0,Xb.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return U.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){U.error(s)}}]}var Qb=()=>/Mac/i.test(navigator.platform);var Jb=w(ie()),ir=w(H());var Kh={};$e(Kh,{enUS:()=>EO,nlNL:()=>bO});var EO={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"}]}]},bO={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 Zb={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var eo=w(b()),Wh=(e,t,n)=>r=>(0,eo.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),CO=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(Kh),s=Wt(),a=A("Login",Zb),l=V("productName"),u=(0,ir.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,ir.useCallback)(g=>{g.preventDefault(),s.send(ns,!0)},[t]),m=(0,ir.useMemo)(()=>g=>(0,eo.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,ir.useCallback)(g=>(0,eo.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:f,hour:v,day:y}=(0,ir.useMemo)(()=>({min:Wh(a,60*10,u),hour:Wh(a,60*60,u),day:Wh(a,60*60*12,u)}),[]);return(0,eo.jsxs)("div",{className:(0,Jb.default)(e,a.root),children:[i("loginPlease",{login:n?d:m,productName:l}),r&&(0,eo.jsxs)(ir.Fragment,{children:[(0,eo.jsx)("br",{}),i("snooze",{min:f,hour:v,day:y})]})]})},Qd=CO;var eC={root:"dd-DoQhb",text:"dd-Jwnev"};var ml=w(b()),TO=({title:e})=>{let t=A("SearchTrigger",eC),n=X();return(0,ml.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Ct(!0)),children:[(0,ml.jsx)(ss,{}),(0,ml.jsx)("span",{className:t.text,children:e})]})},tC=TO;var $h={};$e($h,{enUS:()=>kO,nlNL:()=>PO});var kO={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"}]},PO={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 nC={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var be=w(b()),RO=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=A("SuggestionsOverlay",nC),o=q($h),i=M(Rn),s=T1(),a=X(),l=(0,ms.useRef)(null),u=V("searchTriggerKey"),c=V("productName"),m=M($d),d=M(rt),f=M(Ji),[v,y]=(0,ms.useState)(null),g=V("showSearch"),p=V("showTextSuggestions"),h=V("adminUrl"),S=V("isEmbedded"),[x,T]=Yb("dd-snooze-until-ms",0),C=m||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&T(0),a(Bb(!C))},_=D=>{let G=Date.now()+D*1e3;T(G),U.info(`Snooze until: ${new Date(G)}`),a(Jr({collapse:!0}))};return(0,ms.useEffect)(()=>{R===0&&y(null)},[e,R]),Zr(()=>{a(Jr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||f===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,Zd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1}}),(0,be.jsx)("div",{className:r.triggersRight,children:(0,be.jsx)(po,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(po,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),(0,be.jsx)("div",{className:r.collapsible,children:(0,be.jsx)(Qd,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,Zd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:g&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(Qb()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,be.jsx)(tC,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,Zd.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,be.jsx)(po,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})]})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(po,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),R>0&&p&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(mt,{children:(0,be.jsx)(Xd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},AO=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),rC=$n(AO)(RO);var mf=w(ie());var ur=w(H());var gs=w(H());function Jd(e){return e.contentEditable==="true"}function LO(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),i=o.cloneRange();i.selectNodeContents(e),i.setEnd(o.endContainer,o.endOffset),n=i.toString().length,i.selectNodeContents(e),i.setEnd(o.startContainer,o.startOffset),t=i.toString().length}return{selectionStart:t,selectionEnd:n}}function oC(e){let{selectionStart:t,selectionEnd:n}=Jd(e)?LO(e):e;return[t,n]}function iC(e){let[,t]=(0,gs.useState)(),n=(0,gs.useRef)(null);return n.current=oC(e),(0,gs.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=oC(e);(!s||o!==s[0]||i!==s[1])&&(n.current=s,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function sC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(tu);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var aC=w(H()),IO=["div","span","mark","strong","b","i","u","em"];function qh(e,t,n=0){var i;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(i=r.props)==null?void 0:i.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(IO.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,aC.cloneElement)(r,{children:qh(s,t,n+1)})]}return[...e,...t]}function to(e){return e.tagName.toLowerCase()==="textarea"}var lC={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var vC=w(ie());var uf=w(H());var hs=w(H());function uC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function ef(e){let t=(0,hs.useRef)(null),[n,r]=(0,hs.useState)(!1);return(0,hs.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=uC((m,d)=>{let f=t.current;if(!f)return;let v=m/i,y=d/i,g=f.getBoundingClientRect(),p=v>g.x&&v<g.x+g.width&&y>g.y&&y<g.y+g.height;p&&!o?(o=!0,r(!0)):!p&&o&&(o=!1,r(!1))},({clientX:m,clientY:d})=>[m,d]),[l,u]=uC(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function cC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function tf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function dC(e){return e!=null}var Xh=w(ie()),qt=w(H());var nf=w(H()),NO=["bottom","height","left","right","top","width"],OO=(e={},t={})=>NO.some(n=>e[n]!==t[n]),sr=new Map,fC,pC=()=>{let e=[],t=[];sr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();OO(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{sr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),fC=window.requestAnimationFrame(pC)};function MO(e,t){return{observe(){let n=sr.size===0;if(sr.has(e)){let r=sr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else sr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&pC()},unobserve(){let n=sr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||sr.delete(e),sr.size||cancelAnimationFrame(fC)}}}}function Gh(e){let[t,n]=(0,nf.useState)(null);return(0,nf.useLayoutEffect)(()=>{if(!e.current)return;let r=MO(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var ys=w(H()),gC=w(gc());var mC={root:"dd-r-dgo"};var hC=({children:e,parentNode:t})=>{let[n,r]=(0,ys.useState)(null),o=(0,ys.useContext)(Ls);return(0,ys.useLayoutEffect)(()=>{let i=document.createElement("div");return Wo(i),i.classList.add(mC.root),o!=null&&o.portalRootNode&&i.classList.add(o==null?void 0:o.portalRootNode),(t||document.body).appendChild(i),r(i),()=>{i.isConnected&&i.remove()}},[]),n?(0,gC.createPortal)(e,n):null};var An={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var rf=w(b()),of=(e=!1)=>{let[t,n]=(0,qt.useState)(e),r=(0,qt.useCallback)(()=>n(!0),[]),o=(0,qt.useCallback)(()=>n(!1),[]),i=(0,qt.useCallback)(()=>n(a=>!a),[]),s=(0,qt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function Yh(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var vs=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,qt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=Yh,parentNode:a}=c,l=te(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let m=Gh(t),d=Gh(n),f=(0,qt.useMemo)(()=>s(m,d,0),[m,d]);return(0,rf.jsx)(hC,{parentNode:a,children:(0,rf.jsx)("div",O(P({className:(0,Xh.default)(An.ref,{[An.positionAbove]:r==="above",[An.positionBelow]:r==="below",[An.positionLeft]:r==="left",[An.positionRight]:r==="right",[An.alignStart]:o==="start",[An.alignCenter]:o==="center",[An.alignEnd]:o==="end"}),style:f},l),{role:"dialog",children:(0,rf.jsx)("div",{className:(0,Xh.default)(e,An.root),children:i})}))})};var yC=w(ie()),sf=w(H());var ar={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var Qh=w(b()),af=(0,sf.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=te(i,["className","children"]);let s=(0,sf.useRef)(null),a=A("TabCompletion",ar);return(0,Qh.jsx)("div",O(P({ref:tf([s,r]),className:(0,yC.default)(e,a.popoverContentContainer)},n),{children:(0,Qh.jsx)("div",{className:a.popoverContent,children:t})}))});var no=w(b()),_O=e=>t=>{let n=Yh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},DO=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=A("TabCompletion",ar),s=of(),a=(0,uf.useMemo)(()=>_O(e.getBoundingClientRect()),[e]),[l,u]=ef(e);return(0,uf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,no.jsxs)("span",{children:[(0,no.jsx)("mark",{ref:tf([l,s.triggerRef]),className:(0,vC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,no.jsx)(vs,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,no.jsx)(af,{style:n,children:(0,no.jsx)("div",{className:i.hintText,children:o})})})]})},lf=class extends Zn{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>O(P({},o),{keywordRegex:new RegExp(`\\b${cC(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(dC);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,no.jsx)(DO,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var SC=w(ie());var Zh=w(b()),FO=({inputElement:e,children:t})=>{let n=A("TabCompletion",ar),[r,o]=ef(e);return(0,Zh.jsx)("mark",{ref:r,className:(0,SC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},cf=class extends Zn{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,Zh.jsx)(FO,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var ff=w(ie());var at=w(H());var Jh=w(b()),wC=()=>(0,Jh.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,Jh.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 ro=w(H());var EC=w(hh());var xC={root:"dd-ky-Bv",content:"dd-kV5e1"};function df(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(i){return null}}function ey(e){return e.replace("https://www.","").replace("https://","")}var Gt=w(b()),HO=3,UO=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),zO=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=HO})=>{let i=A("LinkSearch",xC),[s,a]=(0,ro.useState)(""),l=X(),u=M(vb("url")),c=M($1("URL",UO)),[m,d]=(0,ro.useState)(c.length-1),f=V("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},g=h=>{var T;let S=m-1<0?c.length-1:m-1,x=m+1===c.length?0:m+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((T=c[m])==null?void 0:T.text)||s)},p=(0,ro.useCallback)((0,EC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,ro.useEffect)(()=>{s&&p(s)},[s]),(0,ro.useEffect)(()=>()=>{l(ud())},[]),(0,Gt.jsxs)("div",{className:i.root,children:[(0,Gt.jsx)(mt,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Gt.jsx)(oe,{selected:m===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Gt.jsxs)(ye,{children:[(0,Gt.jsx)(ye.Image,{src:df(h,"small",f||void 0),title:h.title||h.text}),(0,Gt.jsxs)(ye.Content,{className:i.content,cropText:!0,children:[(0,Gt.jsx)(ye.Title,{children:h.title||ey(h.text)}),h.title&&ey(h.text)]}),(0,Gt.jsx)(oe.Actions,{children:(0,Gt.jsx)(oe.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Gt.jsx)(Ga,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},bC=zO;var ty={};$e(ty,{enUS:()=>BO,nlNL:()=>jO});var BO={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},jO={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var st=w(b()),VO=(0,at.forwardRef)((e,t)=>{let n=A("TabCompletion",ar);return(0,st.jsx)("mark",{ref:t,className:(0,ff.default)(n.matchSelection)},"selection-start")}),KO=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(ty),s=A("TabCompletion",ar),a=(0,at.useRef)(null),l=(0,at.useRef)(null),[u,c]=(0,at.useState)(null),m=X(),d=of(document.activeElement===r),[f]=(0,at.useState)(()=>document.createRange());d.triggerRef.current=f,(0,at.useEffect)(()=>()=>f.detach(),[]),(0,at.useEffect)(()=>{let y=e.current,g=a.current;!y||!g||(f.setStart(y,0),f.setEnd(g,0))},[e.current,a.current]),Zr(()=>{d.close()});let v=(0,at.useCallback)(y=>{let g=f.toString(),p=/^http(s?):\/\//.test(y)?y:`https://${y}`;m(rd({text:`[${g}](${p})`,replace:"selection"}))},[]);return(0,st.jsxs)("span",{children:[(0,st.jsx)("mark",{ref:a,className:(0,ff.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,st.jsx)(vs,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,st.jsxs)(af,{style:n,ref:l,children:[(0,st.jsx)("div",{className:(0,ff.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,st.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,st.jsx)(wC,{}),(0,st.jsx)("span",{children:"\xA0"}),(0,st.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,st.jsx)(bC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},pf=class extends Zn{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,at.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?P({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,st.jsx)(VO,{ref:this.startRef}):(0,st.jsx)(KO,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var lr=w(b()),WO=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=A("TabCompletion",lC),c=V("insertLink"),m=V("showMidSentenceSuggestions"),d=V("inlineSuggestions"),f=iC(a),v=(0,ur.useRef)(null),y=M(rt);(0,ur.useEffect)(()=>{to(a)&&f&&sC(a,f)},[f]);let g=(0,ur.useCallback)(S=>{if(!o||!n)return S;let x=[(0,lr.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,lr.jsx)("span",{"data-testid":"tab-completion",className:(0,mf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,lr.jsx)("span",{className:(0,mf.default)(u.hint,u.resetIndent),children:(0,lr.jsx)(Ql,{keyCode:"tab"},"tabHint")})),qh(S,x)},[o,n,r]),p=(0,ur.useMemo)(()=>{let S=[];return c&&S.push(new pf("selection")),S.push(new cf("placeholders")),i&&S.push(new lf("keywords")),S},[d,c,i]),h=(0,ur.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!e||!y?null:(0,lr.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,lr.jsx)(rs,{tagName:"span",containerTagName:"div",className:(0,mf.default)(u.container,u.agentText),disableLineBreaks:to(a),content:t||"\u200B",onAfterParse:g,matchers:p,selection:f,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!m}),(0,lr.jsx)("br",{})]})},$O=e=>{var g,p,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=ts({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(g=t.html)!=null?g:os(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:m}=n,{isSupported:d}=i,{showTabCompletion:f,visible:v,showStyleSuggestions:y}=r;return{showTabHint:m,showStyleSuggestions:y,showTabCompletion:f&&Rn(e),content:u,tabText:c,source:l,keywordMatches:(h=(p=o.list)==null?void 0:p.keywordMatches)!=null?h:[],enabled:v&&d!==!1}},CC=$n($O)(WO);var UT=w(ie()),Pl=w(H());var TC={list:[],fetchState:"idle"},PC=e=>e.autoflows.list||[],kC=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},cr=K("autoflows/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),ny=K("autoflows/start",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.startAutoflowSession(e),yield n(cr(e.platformSessionId))})),ry=K("autoflows/stop",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.stopAutoflowSession(e.platformSessionId),yield n(cr(e.platformSessionId))})),qO=Q({name:"autoflows",initialState:TC,reducers:{},extraReducers:e=>{e.addCase(ny.pending,(t,n)=>{let r=kC(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(ry.pending,(t,n)=>{let r=kC(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(cr.pending,t=>{t.fetchState="loading"}),e.addCase(cr.rejected,t=>{t.fetchState="error"}),e.addCase(cr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(fe,()=>TC)}}),RC=K("autoflows/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");let o=r.openStream(e);o.on("sessionAborted",()=>{n(cr(e))}),o.on("sessionCompleted",()=>{n(cr(e))})}),AC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),LC=qO.reducer;var IC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},NC=e=>e.customMessages.list,OC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),MC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),_C=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),gl=K("customMessages/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),gf=K("customMessages/send",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.sendCustomMessage(n,r)})),hf=K("customMessages/answer",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.answerCustomMessage(n,r)})),DC=Q({name:"customMessages",initialState:IC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(gl.pending,t=>{t.fetchState="loading"}).addCase(gl.rejected,t=>{t.fetchState="error"}).addCase(gl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(gf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(gf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(hf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(hf.rejected,(t,n)=>{let r=t.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1)),t.answeredSuggestions.splice(r,1)}).addCase(fe,()=>IC)}}),FC=K("customMessages/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");r.openStream(e).on("customMessageSuggestion",i=>{n(DC.actions.onCustomMessage(i))})}),HC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),UC=DC.reducer;var GO={token:null,interval:null},oy=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),iy=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(oy()),setInterval(()=>r(oy()),n)}),zC=Q({name:"passwordlessToken",initialState:GO,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(oy.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(iy.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:BC}=zC.actions,jC=zC.reducer;var VC={shouldEmit:!0},sy={cues:[],fetchState:"idle"},KC=e=>{var t;return(t=e.rules)==null?void 0:t.cues},XO=Re("rules/resetCues"),Go=K("rules/evaluate",(e,t)=>k(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),s=(n=i.conversation.current)==null?void 0:n.id;if(!s)throw new Error("No current conversation to evaluate rules");if(!(yield o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(yield o.getRules()).filter(m=>m.isEnabled).some(m=>m.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);return{cues:yield o.evaluateRule(e.label,s,P({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.params)),options:e.options}}catch(o){let i=o.message;return U.warn(i),t.rejectWithValue(i)}})),WC=Q({name:"answer",initialState:sy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Go.pending,t=>{t.fetchState="loading"}).addCase(Go.rejected,t=>{t.fetchState="error"}).addCase(Go.fulfilled,(t,n)=>{let r=n.payload.cues.map(i=>i.rule.id),o=t.cues.filter(i=>!r.includes(i.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(fe,()=>sy).addCase(XO.toString(),()=>sy)}}),{removeCue:$C}=WC.actions,qC=WC.reducer;var nT=w(H());var JC=w(ie()),eT=w(H());var XC=w(ie());var GC={root:"dd-uszkm"};var QC=w(b()),YO=({className:e,children:t})=>{let n=A("Unicode",GC);return(0,QC.jsx)("span",{className:(0,XC.default)(e,n.root),children:t})},YC=YO;var ZC={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var ay={};$e(ay,{enUS:()=>QO,nlNL:()=>ZO});var QO={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"}]},ZO={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 Rt=w(b()),eM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=A("Autoflow",ZC),a=q(ay),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,Rt.jsxs)(oe,{className:(0,JC.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,Rt.jsx)(ye,{children:(0,Rt.jsxs)(ye.Content,{children:[(0,Rt.jsxs)(ye.Title,{children:[t&&(0,Rt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,Rt.jsx)("span",{children:r})]})}),(0,Rt.jsx)(oe.Actions,{fixed:t==="Started",children:(0,Rt.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,Rt.jsxs)(eT.Fragment,{children:[(0,Rt.jsx)(YC,{children:u})," ",(0,Rt.jsx)("span",{children:a(l)})]})})})]})},tT=eM;var ly=w(b()),tM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},nM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,ly.jsx)(nT.Fragment,{children:e.map(o=>(0,ly.jsx)(tT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||tM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),rM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},oM={onStartAutoflow:ny,onStopAutoflow:ry},rT=$n(rM,oM)(nM);var oT=w(ie()),uy=w(H());var dr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var St=w(b()),iM=({suggestion:e})=>{let t=q(Vo),n=X(),r=M(OC(e.text)),o=M(MC(e.text)),i=M(_C(e.text)),s=M(Zi),{replyOptions:a}=e,l=(0,uy.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(gf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,uy.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let m=parseInt(c.target.dataset.index,10),d=a[m];n(hf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,St.jsxs)(oe,{onClick:l,className:(0,oT.default)(dr.root,{[dr.isUsed]:r,[dr.hasError]:i}),children:[(0,St.jsx)(ye,{children:(0,St.jsxs)(ye.Content,{children:[(0,St.jsxs)(ye.Title,{className:dr.title,children:[e.text," ",(0,St.jsx)(Zl,{className:dr.label,children:"analyse tool"})," ",i&&(0,St.jsx)("span",{className:dr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,St.jsx)("ul",{className:dr.quickReplies,children:a.map(c=>(0,St.jsx)("li",{className:dr.quickReply,children:c.title},c.title))})]})}),(0,St.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,St.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,m)=>(0,St.jsx)(oe.DropdownItem,{index:m,label:c.title,onClick:u},c.title))}),(0,St.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},iT=iM;var yf=w(H());var dy=w(ie());var cy=w(b()),hl=()=>(0,cy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,cy.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 sT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Ln=w(b()),sM=({entities:e})=>{let t=A("EntitiesWidgetList",sT),[n,r]=(0,yf.useState)(void 0),o=X(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Yn(a.text),o(ot({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,yf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Ln.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Ln.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Ln.jsx)("span",{className:t.entityText,children:a.text}),(0,Ln.jsxs)("span",{className:t.iconWrapper,children:[(0,Ln.jsx)("span",{className:(0,dy.default)(t.icon),children:(0,Ln.jsx)(hl,{})}),(0,Ln.jsx)("span",{className:(0,dy.default)(t.icon,n===l&&t.iconClicked),children:(0,Ln.jsx)(hl,{})})]})]},a.text))})},aT=sM;var fy=w(b()),lT=()=>(0,fy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,fy.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 py=w(b()),uT=()=>(0,py.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,py.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 my=w(b()),cT=()=>(0,my.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,my.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 AT=w(H());var yl=w(b()),dT=({className:e})=>(0,yl.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,yl.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,yl.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var{entries:ST,setPrototypeOf:fT,isFrozen:aM,getPrototypeOf:lM,getOwnPropertyDescriptor:uM}=Object,{freeze:lt,seal:mn,create:wT}=Object,{apply:wy,construct:xy}=typeof Reflect!="undefined"&&Reflect;lt||(lt=function(t){return t});mn||(mn=function(t){return t});wy||(wy=function(t,n,r){return t.apply(n,r)});xy||(xy=function(t,n){return new t(...n)});var vf=Lt(Array.prototype.forEach),pT=Lt(Array.prototype.pop),vl=Lt(Array.prototype.push),xf=Lt(String.prototype.toLowerCase),gy=Lt(String.prototype.toString),cM=Lt(String.prototype.match),Sl=Lt(String.prototype.replace),dM=Lt(String.prototype.indexOf),fM=Lt(String.prototype.trim),pn=Lt(Object.prototype.hasOwnProperty),At=Lt(RegExp.prototype.test),wl=pM(TypeError);function Lt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return wy(e,t,r)}}function pM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return xy(e,n)}}function ee(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xf;fT&&fT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(aM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function mM(e){for(let t=0;t<e.length;t++)pn(e,t)||(e[t]=null);return e}function Xo(e){let t=wT(null);for(let[n,r]of ST(e))pn(e,n)&&(Array.isArray(r)?t[n]=mM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Xo(r):t[n]=r);return t}function Sf(e,t){for(;e!==null;){let r=uM(e,t);if(r){if(r.get)return Lt(r.get);if(typeof r.value=="function")return Lt(r.value)}e=lM(e)}function n(){return null}return n}var mT=lt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),hy=lt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),yy=lt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),gM=lt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),vy=lt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hM=lt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),gT=lt(["#text"]),hT=lt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),Sy=lt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),yT=lt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),wf=lt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yM=mn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),vM=mn(/<%[\w\W]*|[\w\W]*%>/gm),SM=mn(/\${[\w\W]*}/gm),wM=mn(/^data-[\-\w.\u00B7-\uFFFF]/),xM=mn(/^aria-[\-\w]+$/),xT=mn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),EM=mn(/^(?:\w+script|data):/i),bM=mn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ET=mn(/^html$/i),vT=Object.freeze({__proto__:null,MUSTACHE_EXPR:yM,ERB_EXPR:vM,TMPLIT_EXPR:SM,DATA_ATTR:wM,ARIA_ATTR:xM,IS_ALLOWED_URI:xT,IS_SCRIPT_OR_DATA:EM,ATTR_WHITESPACE:bM,DOCTYPE_NAME:ET}),CM=function(){return typeof window=="undefined"?null:window},TM=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function bT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:CM(),t=j=>bT(j);if(t.version="3.0.9",t.removed=[],!e||!e.document||e.document.nodeType!==9)return t.isSupported=!1,t;let{document:n}=e,r=n,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:s,Node:a,Element:l,NodeFilter:u,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:m,DOMParser:d,trustedTypes:f}=e,v=l.prototype,y=Sf(v,"cloneNode"),g=Sf(v,"nextSibling"),p=Sf(v,"childNodes"),h=Sf(v,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let S,x="",{implementation:T,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof ST=="function"&&typeof h=="function"&&T&&T.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:se,DATA_ATTR:mr,ARIA_ATTR:It,IS_SCRIPT_OR_DATA:gr,ATTR_WHITESPACE:Nt}=vT,{IS_ALLOWED_URI:B}=vT,J=null,hr=ee({},[...mT,...hy,...yy,...vy,...gT]),we=null,yr=ee({},[...hT,...Sy,...yT,...wf]),Y=Object.seal(wT(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),vr=null,_l=null,ei=!0,ao=!0,Cs=!1,Dl=!0,Qt=!1,Zt=!1,Fl=!1,ut=!1,Ot=!1,Hl=!1,Ul=!1,Dy=!0,Fy=!1,Ik="user-content-",Of=!0,Ts=!1,ti={},ni=null,Hy=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Uy=null,zy=ee({},["audio","video","img","source","image","track"]),Mf=null,By=ee({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zl="http://www.w3.org/1998/Math/MathML",Bl="http://www.w3.org/2000/svg",Mn="http://www.w3.org/1999/xhtml",ri=Mn,_f=!1,Df=null,Nk=ee({},[zl,Bl,Mn],gy),ks=null,Ok=["application/xhtml+xml","text/html"],Mk="text/html",De=null,oi=null,_k=n.createElement("form"),jy=function(E){return E instanceof RegExp||E instanceof Function},Ff=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(oi&&oi===E)){if((!E||typeof E!="object")&&(E={}),E=Xo(E),ks=Ok.indexOf(E.PARSER_MEDIA_TYPE)===-1?Mk:E.PARSER_MEDIA_TYPE,De=ks==="application/xhtml+xml"?gy:xf,J=pn(E,"ALLOWED_TAGS")?ee({},E.ALLOWED_TAGS,De):hr,we=pn(E,"ALLOWED_ATTR")?ee({},E.ALLOWED_ATTR,De):yr,Df=pn(E,"ALLOWED_NAMESPACES")?ee({},E.ALLOWED_NAMESPACES,gy):Nk,Mf=pn(E,"ADD_URI_SAFE_ATTR")?ee(Xo(By),E.ADD_URI_SAFE_ATTR,De):By,Uy=pn(E,"ADD_DATA_URI_TAGS")?ee(Xo(zy),E.ADD_DATA_URI_TAGS,De):zy,ni=pn(E,"FORBID_CONTENTS")?ee({},E.FORBID_CONTENTS,De):Hy,vr=pn(E,"FORBID_TAGS")?ee({},E.FORBID_TAGS,De):{},_l=pn(E,"FORBID_ATTR")?ee({},E.FORBID_ATTR,De):{},ti=pn(E,"USE_PROFILES")?E.USE_PROFILES:!1,ei=E.ALLOW_ARIA_ATTR!==!1,ao=E.ALLOW_DATA_ATTR!==!1,Cs=E.ALLOW_UNKNOWN_PROTOCOLS||!1,Dl=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qt=E.SAFE_FOR_TEMPLATES||!1,Zt=E.WHOLE_DOCUMENT||!1,Ot=E.RETURN_DOM||!1,Hl=E.RETURN_DOM_FRAGMENT||!1,Ul=E.RETURN_TRUSTED_TYPE||!1,ut=E.FORCE_BODY||!1,Dy=E.SANITIZE_DOM!==!1,Fy=E.SANITIZE_NAMED_PROPS||!1,Of=E.KEEP_CONTENT!==!1,Ts=E.IN_PLACE||!1,B=E.ALLOWED_URI_REGEXP||xT,ri=E.NAMESPACE||Mn,Y=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&jy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&jy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qt&&(ao=!1),Hl&&(Ot=!0),ti&&(J=ee({},gT),we=[],ti.html===!0&&(ee(J,mT),ee(we,hT)),ti.svg===!0&&(ee(J,hy),ee(we,Sy),ee(we,wf)),ti.svgFilters===!0&&(ee(J,yy),ee(we,Sy),ee(we,wf)),ti.mathMl===!0&&(ee(J,vy),ee(we,yT),ee(we,wf))),E.ADD_TAGS&&(J===hr&&(J=Xo(J)),ee(J,E.ADD_TAGS,De)),E.ADD_ATTR&&(we===yr&&(we=Xo(we)),ee(we,E.ADD_ATTR,De)),E.ADD_URI_SAFE_ATTR&&ee(Mf,E.ADD_URI_SAFE_ATTR,De),E.FORBID_CONTENTS&&(ni===Hy&&(ni=Xo(ni)),ee(ni,E.FORBID_CONTENTS,De)),Of&&(J["#text"]=!0),Zt&&ee(J,["html","head","body"]),J.table&&(ee(J,["tbody"]),delete vr.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw wl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw wl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,x=S.createHTML("")}else S===void 0&&(S=TM(f,o)),S!==null&&typeof x=="string"&&(x=S.createHTML(""));lt&&lt(E),oi=E}},Vy=ee({},["mi","mo","mn","ms","mtext"]),Ky=ee({},["foreignobject","desc","title","annotation-xml"]),Dk=ee({},["title","style","font","a","script"]),Wy=ee({},[...hy,...yy,...gM]),$y=ee({},[...vy,...hM]),Fk=function(E){let I=h(E);(!I||!I.tagName)&&(I={namespaceURI:ri,tagName:"template"});let z=xf(E.tagName),me=xf(I.tagName);return Df[E.namespaceURI]?E.namespaceURI===Bl?I.namespaceURI===Mn?z==="svg":I.namespaceURI===zl?z==="svg"&&(me==="annotation-xml"||Vy[me]):!!Wy[z]:E.namespaceURI===zl?I.namespaceURI===Mn?z==="math":I.namespaceURI===Bl?z==="math"&&Ky[me]:!!$y[z]:E.namespaceURI===Mn?I.namespaceURI===Bl&&!Ky[me]||I.namespaceURI===zl&&!Vy[me]?!1:!$y[z]&&(Dk[z]||!Wy[z]):!!(ks==="application/xhtml+xml"&&Df[E.namespaceURI]):!1},lo=function(E){vl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(I){E.remove()}},Hf=function(E,I){try{vl(t.removed,{attribute:I.getAttributeNode(E),from:I})}catch(z){vl(t.removed,{attribute:null,from:I})}if(I.removeAttribute(E),E==="is"&&!we[E])if(Ot||Hl)try{lo(I)}catch(z){}else try{I.setAttribute(E,"")}catch(z){}},qy=function(E){let I=null,z=null;if(ut)E="<remove></remove>"+E;else{let We=cM(E,/^[\r\n\t ]+/);z=We&&We[0]}ks==="application/xhtml+xml"&&ri===Mn&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let me=S?S.createHTML(E):E;if(ri===Mn)try{I=new d().parseFromString(me,ks)}catch(We){}if(!I||!I.documentElement){I=T.createDocument(ri,"template",null);try{I.documentElement.innerHTML=_f?x:me}catch(We){}}let Ke=I.body||I.documentElement;return E&&z&&Ke.insertBefore(n.createTextNode(z),Ke.childNodes[0]||null),ri===Mn?N.call(I,Zt?"html":"body")[0]:Zt?I.documentElement:Ke},Gy=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null)},Hk=function(E){return E instanceof m&&(typeof E.nodeName!="string"||typeof E.textContent!="string"||typeof E.removeChild!="function"||!(E.attributes instanceof c)||typeof E.removeAttribute!="function"||typeof E.setAttribute!="function"||typeof E.namespaceURI!="string"||typeof E.insertBefore!="function"||typeof E.hasChildNodes!="function")},Xy=function(E){return typeof a=="function"&&E instanceof a},_n=function(E,I,z){D[E]&&vf(D[E],me=>{me.call(t,I,z,oi)})},Yy=function(E){let I=null;if(_n("beforeSanitizeElements",E,null),Hk(E))return lo(E),!0;let z=De(E.nodeName);if(_n("uponSanitizeElement",E,{tagName:z,allowedTags:J}),E.hasChildNodes()&&!Xy(E.firstElementChild)&&At(/<[/\w]/g,E.innerHTML)&&At(/<[/\w]/g,E.textContent))return lo(E),!0;if(!J[z]||vr[z]){if(!vr[z]&&Zy(z)&&(Y.tagNameCheck instanceof RegExp&&At(Y.tagNameCheck,z)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(z)))return!1;if(Of&&!ni[z]){let me=h(E)||E.parentNode,Ke=p(E)||E.childNodes;if(Ke&&me){let We=Ke.length;for(let ct=We-1;ct>=0;--ct)me.insertBefore(y(Ke[ct],!0),g(E))}}return lo(E),!0}return E instanceof l&&!Fk(E)||(z==="noscript"||z==="noembed"||z==="noframes")&&At(/<\/no(script|embed|frames)/i,E.innerHTML)?(lo(E),!0):(Qt&&E.nodeType===3&&(I=E.textContent,vf([G,Z,se],me=>{I=Sl(I,me," ")}),E.textContent!==I&&(vl(t.removed,{element:E.cloneNode()}),E.textContent=I)),_n("afterSanitizeElements",E,null),!1)},Qy=function(E,I,z){if(Dy&&(I==="id"||I==="name")&&(z in n||z in _k))return!1;if(!(ao&&!_l[I]&&At(mr,I))){if(!(ei&&At(It,I))){if(!we[I]||_l[I]){if(!(Zy(E)&&(Y.tagNameCheck instanceof RegExp&&At(Y.tagNameCheck,E)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(E))&&(Y.attributeNameCheck instanceof RegExp&&At(Y.attributeNameCheck,I)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(I))||I==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&At(Y.tagNameCheck,z)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(z))))return!1}else if(!Mf[I]){if(!At(B,Sl(z,Nt,""))){if(!((I==="src"||I==="xlink:href"||I==="href")&&E!=="script"&&dM(z,"data:")===0&&Uy[E])){if(!(Cs&&!At(gr,Sl(z,Nt,"")))){if(z)return!1}}}}}}return!0},Zy=function(E){return E!=="annotation-xml"&&E.indexOf("-")>0},Jy=function(E){_n("beforeSanitizeAttributes",E,null);let{attributes:I}=E;if(!I)return;let z={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we},me=I.length;for(;me--;){let Ke=I[me],{name:We,namespaceURI:ct,value:uo}=Ke,Ps=De(We),dt=We==="value"?uo:fM(uo);if(z.attrName=Ps,z.attrValue=dt,z.keepAttr=!0,z.forceKeepAttr=void 0,_n("uponSanitizeAttribute",E,z),dt=z.attrValue,z.forceKeepAttr||(Hf(We,E),!z.keepAttr))continue;if(!Dl&&At(/\/>/i,dt)){Hf(We,E);continue}Qt&&vf([G,Z,se],tv=>{dt=Sl(dt,tv," ")});let ev=De(E.nodeName);if(Qy(ev,Ps,dt)){if(Fy&&(Ps==="id"||Ps==="name")&&(Hf(We,E),dt=Ik+dt),S&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ct)switch(f.getAttributeType(ev,Ps)){case"TrustedHTML":{dt=S.createHTML(dt);break}case"TrustedScriptURL":{dt=S.createScriptURL(dt);break}}try{ct?E.setAttributeNS(ct,We,dt):E.setAttribute(We,dt),pT(t.removed)}catch(tv){}}}_n("afterSanitizeAttributes",E,null)},Uk=function j(E){let I=null,z=Gy(E);for(_n("beforeSanitizeShadowDOM",E,null);I=z.nextNode();)_n("uponSanitizeShadowNode",I,null),!Yy(I)&&(I.content instanceof i&&j(I.content),Jy(I));_n("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=null,z=null,me=null,Ke=null;if(_f=!j,_f&&(j="<!-->"),typeof j!="string"&&!Xy(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw wl("dirty is not a string, aborting")}else throw wl("toString is not a function");if(!t.isSupported)return j;if(Fl||Ff(E),t.removed=[],typeof j=="string"&&(Ts=!1),Ts){if(j.nodeName){let uo=De(j.nodeName);if(!J[uo]||vr[uo])throw wl("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)I=qy("<!---->"),z=I.ownerDocument.importNode(j,!0),z.nodeType===1&&z.nodeName==="BODY"||z.nodeName==="HTML"?I=z:I.appendChild(z);else{if(!Ot&&!Qt&&!Zt&&j.indexOf("<")===-1)return S&&Ul?S.createHTML(j):j;if(I=qy(j),!I)return Ot?null:Ul?x:""}I&&ut&&lo(I.firstChild);let We=Gy(Ts?j:I);for(;me=We.nextNode();)Yy(me)||(me.content instanceof i&&Uk(me.content),Jy(me));if(Ts)return j;if(Ot){if(Hl)for(Ke=R.call(I.ownerDocument);I.firstChild;)Ke.appendChild(I.firstChild);else Ke=I;return(we.shadowroot||we.shadowrootmode)&&(Ke=_.call(r,Ke,!0)),Ke}let ct=Zt?I.outerHTML:I.innerHTML;return Zt&&J["!doctype"]&&I.ownerDocument&&I.ownerDocument.doctype&&I.ownerDocument.doctype.name&&At(ET,I.ownerDocument.doctype.name)&&(ct="<!DOCTYPE "+I.ownerDocument.doctype.name+`>
24
- `+ct),Qt&&vf([G,Z,se],uo=>{ct=Sl(ct,uo," ")}),S&&Ul?S.createHTML(ct):ct},t.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ff(j),Fl=!0},t.clearConfig=function(){oi=null,Fl=!1},t.isValidAttribute=function(j,E,I){oi||Ff({});let z=De(j),me=De(E);return Qy(z,me,I)},t.addHook=function(j,E){typeof E=="function"&&(D[j]=D[j]||[],vl(D[j],E))},t.removeHook=function(j){if(D[j])return pT(D[j])},t.removeHooks=function(j){D[j]&&(D[j]=[])},t.removeAllHooks=function(){D={}},t}var CT=bT();var oo=w(H());var kM={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function TT(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function xl(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function El(e,t){var n,r,o,i,s,a=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,l=[],u="",c=t||{},m=0;function d(v){var y=kM[v[1]||""],g=l[l.length-1]==v;return y?y[1]?(g?l.pop():l.push(v),y[0|g]):y[0]:v}function f(){for(var v="";l.length;)v+=d(l[l.length-1]);return v}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(v,y,g){return c[y.toLowerCase()]=g,""}).replace(/^\n+|\n+$/g,"");o=a.exec(e);)r=e.substring(m,o.index),m=a.lastIndex,n=o[0],r.match(/[^\\](\\\\)*\\$/)||((s=o[3]||o[4])?n='<pre class="code '+(o[4]?"poetry":o[2].toLowerCase())+'"><code'+(o[2]?' class="language-'+o[2].toLowerCase()+'"':"")+">"+TT(xl(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=El(TT(o[5].replace(/^\s*[>*+.-]/gm,""))),s==">"?s="blockquote":(s=s.match(/\./)?"ol":"ul",i=i.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),n="<"+s+">"+i+"</"+s+">"):o[8]?n='<img src="'+xl(o[8])+'" alt="'+xl(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+xl(o[11]||c[r.toLowerCase()])+'">'),n=f()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+El(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+xl(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(m)+f()).replace(/^\n+|\n+$/g,"")}var kT={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var In=w(b());function PM(e){return`<button type="button" class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Ey(e){var n;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(r=>r.remove()),(n=t.textContent)!=null?n:""}function RM(e){return e.replace(/\r\n/g,`
25
- `)}var AM=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=A("Markdown",kT),s=(0,oo.useRef)(null),[a,l]=(0,oo.useState)(null),u=(0,oo.useMemo)(()=>{let y=El(RM(e));return CT.sanitize(y).replace(/<\/code>/g,`${PM(i.copyIcon)}</code>`)},[e]),c=y=>{var h;let g=y.target,p=!!((h=s.current)!=null&&h.querySelector("code"));a||p&&g.tagName!=="CODE"||!p&&g!==s.current||(g.addEventListener("mouseleave",()=>l(null),{once:!0}),l(g))},m=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(ls(y,i.fadeup),r(Ey(a)))},d=y=>{y.target.tagName.toLowerCase()==="button"&&(ls(y.target,i.fadeup),r(Ey(y.target.parentElement)))},f=()=>{a&&(l(null),o(Ey(a)))},v=y=>{if(y===null)return;let g=y.getBoundingClientRect();g.left<0?y.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,In.jsxs)(oo.Fragment,{children:[a&&(0,In.jsxs)(vs,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,In.jsxs)("div",{className:i.options,ref:v,children:[(0,In.jsx)("button",{type:"button",className:i.option,onClick:m,children:n}),(0,In.jsx)("div",{className:i.divider}),(0,In.jsx)("button",{type:"button",className:i.option,onClick:f,children:t})]}),(0,In.jsx)("div",{className:i.arrow})]}),(0,In.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},PT=AM;var by={};$e(by,{enUS:()=>LM,nlNL:()=>IM});var LM={useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},IM={useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var RT={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var gn=w(b()),NM=({cue:e,onRemove:t,onCopy:n,onUse:r})=>{let o=A("WidgetCue",RT),i=q(by),s=us(),a=c=>{n&&n(c,e)},l=c=>{r&&r(c,e)},u=c=>{c.preventDefault(),c.stopPropagation(),t(e)};return(0,AT.useEffect)(()=>{s("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,gn.jsxs)(oe,{"data-testid":"cue",children:[(0,gn.jsx)(ye,{children:(0,gn.jsxs)(ye.Content,{children:[e.title&&(0,gn.jsx)(ye.Title,{className:o.title,"data-testid":"widget-cue-title",children:e.title}),(0,gn.jsx)(PT,{content:e.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:a,onUse:l})]})}),(0,gn.jsxs)(oe.IconButtonContainer,{children:[(0,gn.jsx)(ds,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"}),(0,gn.jsx)(oe.IconButton,{title:i("removeCue"),onClick:u,icon:(0,gn.jsx)(dT,{})})]})]})},LT=NM;var bl=w(b()),OM=({cues:e})=>{let t=X(),n=Wt(),r=us(),o=a=>{t($C({id:a.rule.id})),r("Assistant response closed",{name:a.rule.name,group:a.rule.label,description:a.rule.description,cueText:a.text})},i=(a,l)=>{Yn(a),r("Assistant response copied",{name:l.rule.name,group:l.rule.label,description:l.rule.description,copiedText:a})},s=(a,l)=>{n.send(Gr,{text:a,suggestion:{source:"cue",sourceText:a}}),r("Assistant response used",{name:l.rule.name,group:l.rule.label,description:l.rule.description,usedText:a})};return(0,bl.jsx)(bl.Fragment,{children:e.map(a=>(0,bl.jsx)(LT,{cue:a,onRemove:o,onCopy:i,onUse:s},a.rule.id))})},IT=OM;var Ef=w(H());var NT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var hn=w(b());function MM(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var OT=({data:e,schema:t})=>{let n=A("WidgetCustomData",NT),r=o=>{Yn(o)};return(0,Ef.useEffect)(()=>{U.info("Custom data",e,t)},[e]),(0,hn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=MM(e,o.path);return(0,hn.jsxs)(Ef.Fragment,{children:[(0,hn.jsx)("dt",{className:n.label,children:o.label}),(0,hn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,hn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,hn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,hn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,hn.jsx)("span",{children:i}),(0,hn.jsx)(hl,{})]}):"-"})]},o.label)})})};var _T=w(H());var _M=/(https?:\/\/[^\s]+)/,MT=e=>e.split(" ").find(t=>_M.test(t));var Xt=w(b()),DM=({suggestion:e,lines:t,onUse:n})=>{var c;let r=e.text||e.url||e.message,o=MT(r),i=q(Vo),s=V("showImages"),a=V("fallbackImage"),l=m=>{m.preventDefault(),m.stopPropagation(),n(r)},u=(0,_T.useCallback)(m=>{window.open(o,"_blank"),m.stopPropagation(),m.preventDefault()},[o]);return(0,Xt.jsxs)(oe,{onClick:l,"data-testid":"edit-suggestion",children:[(0,Xt.jsxs)(ye,{children:[s&&e.image&&(0,Xt.jsx)(ye.Image,{src:df(e,"small",a||void 0),title:e.title}),(0,Xt.jsxs)(ye.Content,{children:[e.title&&(0,Xt.jsx)(ye.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((c=e.searchKeywords)==null?void 0:c.length)>0&&(0,Xt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,Xt.jsx)(ye.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Xt.jsxs)(oe.Actions,{children:[o&&(0,Xt.jsx)(oe.ActionButton,{onClick:u,label:i("visitUrl")}),(0,Xt.jsx)(oe.ActionButton,{primary:!0,onClick:l,label:i("useSuggestion")})]})]})},DT=DM;var Cl=w(b()),FM=({lines:e,suggestions:t})=>{let n=Wt(),r=(o,i)=>{n.send(Gr,{text:o,suggestion:O(P({},i),{source:i.source,sourceText:i.text})})};return(0,Cl.jsx)(Cl.Fragment,{children:t.map(o=>(0,Cl.jsx)(DT,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},FT=FM;var Tl={};$e(Tl,{enUS:()=>HM,nlNL:()=>UM});var HM={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},UM={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var kl={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var $=w(b()),bf=(e,t)=>{let n=M(rt);(0,Pl.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},zM=({onLogIn:e})=>{let t=A("Widget",kl),n=V("isEmbedded"),r=V("adminUrl");return(0,$.jsx)("div",{className:t.loginText,children:(0,$.jsx)("div",{children:(0,$.jsx)(Qd,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},HT=({text:e})=>{let t=A("Widget",kl);return(0,$.jsx)("div",{className:t.stateText,children:(0,$.jsx)("div",{children:(0,$.jsx)("p",{children:e})})},"notification")},BM=()=>{let e=q(Tl),t=X(),n=A("Widget",kl),r=V("showSearch"),o=V("showSummaryCommand"),i=V("showKnowledgeSearch"),s=M(cs("/admin/")),a=Wt(),l=V("productName"),u=r||o||i||s;return bf(()=>(t(iy()),()=>{t(BC())}),[t]),u?(0,$.jsx)(vn,{title:e("actions"),type:"shortcuts",children:(0,$.jsxs)("div",{className:n.shortcutList,children:[r&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,$.jsx)(ss,{}),e("linkSearch")]}),o&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,$.jsx)(cT,{}),e("linkSummary")]}),i&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,$.jsx)(uT,{}),e("linkKnowledgeSearch")]}),s&&(0,$.jsxs)("a",{className:n.shortcut,target:"_blank",href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:l}),rel:"noreferrer",children:[(0,$.jsx)(lT,{}),e("linkStudioLogin",{productName:l})]})]})}):null},jM=()=>{let e=X(),t=V("showCustomMessages"),n=M(NC),r=M(Zi);return bf(()=>(e(gl(r)),e(FC(r)),()=>{e(HC(r))}),[e,t,r]),!t||n.length===0?null:(0,$.jsx)(vn,{type:"custom-messages","data-testid":"custom-messages",children:(0,$.jsx)(mt,{withDivider:!0,children:n.map(o=>(0,$.jsx)(iT,{suggestion:o},o.text))})})},VM=()=>{let e=q(Tl),t=X(),n=V("showAutoflows"),r=M(PC),o=M(Zi);return bf(()=>(t(cr(o)),t(RC(o)),()=>{t(AC(o))}),[t,n,o]),!n||r.length===0?null:(0,$.jsx)(vn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(rT,{})})})},KM=()=>{let e=X(),t=M(zd),n=M(fb),r=M(KC),o=M(F1),i=M(Hd),s=M(Bd),a=M(or),l=M(qr);return(0,Pl.useEffect)(()=>{!!o&&!n&&U.warn("Custom data provided, but no schema.")},[o,n]),bf(()=>{t.forEach(({type:u})=>{u==="entities"?e(cn()):nu.includes(u)||e(fn(u))})},[e,l,a]),(0,$.jsx)(Pl.Fragment,{children:t.map(({type:u,title:c,amount:m,lines:d,schema:f})=>{var v,y;switch(u){case"entities":return i&&i.length>0&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(aT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(IT,{cues:r})})},u);case"custom-data":return o&&f&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(OT,{data:o,schema:f})})},u);default:return((y=(v=s[u])==null?void 0:v.suggestions)==null?void 0:y.length)>0&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(FT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,m)||[]})})},u)}})})},WM=({onLogIn:e})=>{let t=q(Tl),n=A("Widget",kl),r=M(Ji),o=M(rt),i=M(Zi),s=M(or);return r===!1?(0,$.jsx)(HT,{text:t("notSupported")}):o===!1?(0,$.jsx)(zM,{onLogIn:e}):!s||!i||o===null?(0,$.jsx)(HT,{text:t("waiting")}):(0,$.jsx)("div",{className:(0,UT.default)(n.root),"data-testid":"widget",children:(0,$.jsxs)(Jl,{className:n.sectionList,children:[(0,$.jsx)(BM,{}),(0,$.jsx)(jM,{}),(0,$.jsx)(VM,{}),(0,$.jsx)(KM,{})]})})},zT=WM;function Ss(e){let t=new Range;return t.selectNodeContents(e),t}function BT(e,t,n){try{return io(e,t,n),!0}catch(r){return!1}}function Cf(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Tf(e){return"tagName"in e&&e.tagName==="BR"}var Rl=/[\u200B-\u200D\uFEFF]/g;function io(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,m=/[\u200B-\u200D\uFEFF]/;if(!m.test(l))return u;for(let d=0;d<=l.length;d++)if(m.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Rl,""),m=o+c.length,d=t>=o&&t<=m,f=n>=o&&n<=m;if(d){let v=s(u,t-o);v===0&&!f?r.setStartBefore(l):r.setStart(l,v)}f&&(r.setEnd(l,s(u,n-o)),i=!0),o=m;break}case Node.ELEMENT_NODE:{if(Tf(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Cf(l)&&u&&!Cf(u)&&!Tf(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Al(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(m){let d=m===n,f=m===o;switch(m.nodeType){case Node.TEXT_NODE:{let v=m.textContent;d&&(a=u+v.substring(0,r).replace(Rl,"").length),f&&(l=u+v.substring(0,i).replace(Rl,"").length),u+=v.replace(Rl,"").length;break}case Node.ELEMENT_NODE:{let v=m.nextSibling===null;Tf(m)&&!v&&u++;for(let y=0;y<m.childNodes.length;y++){let g=d&&y===r,p=f&&y===i;if(g&&(a=u),p&&(l=u),l!==void 0||((!g||!s)&&c(m.childNodes[y]),f&&y===i-1&&(l=u),l!==void 0))break}!f&&Cf(m)&&!v&&u++,f&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Ll(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s=-1,a="";function l(u){let c=u===n,m=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,f=m?i:void 0,v=u.textContent.replace(Rl,"");d===0&&f===void 0?a+=v:a+=v.substring(d,f);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Tf(u)&&!d&&(a+=`
23
+ c32.4,32.4,47.8,70,47.8,115.2v70h11.9c9.4,0,17.9,3.4,24.7,10.2C462.1,250,465.5,257.7,465.5,267.9z`})})});var Bh=w(b()),lO={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},Mb=({className:e,color:t})=>(0,Bh.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Bh.jsx)("path",{d:"M172.03 0.0199966H0V86.03C47.5 86.03 86 124.54 86 172.04C86 124.54 124.51 86.03 172.01 86.03C219.51 86.03 258.03 124.54 258.03 172.04C258.03 219.54 219.52 258.05 172.01 258.05C124.5 258.05 86 219.54 86 172.04C86 219.54 47.5 258.05 0 258.05V344.06H172.03C267.04 344.06 344.06 267.04 344.06 172.03C344.06 77.02 267.04 0 172.03 0V0.0199966Z",fill:lO[t||"pink"]})});var _b={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var jh={};$e(jh,{enUS:()=>uO,nlNL:()=>cO});var uO={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},cO={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Ko=w(b()),Fb=({onLogIn:e})=>{let t=q(jh),n=V("floatingMenu"),r=V("productName"),o=X(),i=M(rt),s=A("FloatingMenu",_b);if(i===null||n===!1)return null;let a=()=>{i===!0?o(Ct(!0)):e()};return(0,Ko.jsxs)("button",{className:(0,Db.default)(s.root,{[s.isLoggedIn]:i,[s.isLoggedOut]:!i}),onClick:a,children:[(0,Ko.jsx)("div",{className:s.text,children:t(i?"search":"signin",{productName:r})}),(0,Ko.jsxs)("div",{className:s.icon,children:[(0,Ko.jsx)(Mb,{className:s.logo,color:"pink"}),i===!1&&(0,Ko.jsx)(Ob,{className:s.lock})]})]})};var Yd=w(H());var Hb=w(H());function Zr(e){(0,Hb.useEffect)(()=>{let t=n=>{n.isWithinRoot||e(n)};return document.body.addEventListener("mouseup",t),()=>{document.body.removeEventListener("mouseup",t)}},[e])}function Wo(e){e.addEventListener("mouseup",t=>{t.isWithinRoot=!0},!0)}function Rn(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:i}=e.input;return i.start!==i.end?!1:i.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(i.end))||r&&new RegExp(r).test(o.substring(0,i.end))?!0:n===!1&&r===!1:!1}var dO={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},$d=({ui:e})=>e.overlayCollapsed,Ub=Q({name:"ui",initialState:dO,reducers:{setShowTabHint(e,t){e.showTabHint=t.payload},setInputFocus(e,t){e.overlayCollapsedUserOverwrite!==!0&&(t.payload===!0&&(e.overlayCollapsed=!1),e.inputHasFocus=t.payload)},setOverlayCollapsed(e,t){t.payload.collapse===!1&&(e.openOverlayWhenTyping=!1),!(t.payload.skipWhenInputFocus&&e.inputHasFocus)&&(e.overlayCollapsed=t.payload.collapse)},setOpenOverlayWhenTyping(e,t){e.openOverlayWhenTyping=t.payload},setOverlayCollapsedUserOverwrite(e,t){e.overlayCollapsedUserOverwrite=t.payload,e.overlayCollapsed=t.payload}}}),{setShowTabHint:dl,setInputFocus:qd,setOverlayCollapsed:Jr,setOpenOverlayWhenTyping:zb,setOverlayCollapsedUserOverwrite:Bb}=Ub.actions,jb=Ub.reducer;var Gd=w(H());var ps=w(H());var Vb=w(H());function Kb(e,t,n){(0,Vb.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var Wb={root:"dd-1MBCO",actions:"dd--x4cy",badge:"dd-4Fpkz",formattedText:"dd-EzvTB"};var $o=w(b()),pO=["search","personal-collection-search","search-autocomplete"];function mO(e,t,n,r={}){var i;let o="";return pO.includes(t)?o=AE(kh(e,n,{stripAgentPart:!0}),(i=r.searchKeywords)!=null?i:[n]):o=kh(e,n,r),r.placeholders===!0&&(o=LE(o)),o}var gO=()=>{},hO=({selected:e,suggestion:t})=>{let n=V("inlineSuggestions"),r=M(es),o=V("enableSuggestionFeedback"),i=M(c=>c.input.text),s=X(),a=A("TextSuggestion",Wb),l=(0,ps.useRef)(null);(0,ps.useEffect)(()=>{let c=setTimeout(()=>{s(k1({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(c)}},[t]),Kb(l,"click",()=>{s(rn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let u=(0,ps.useMemo)(()=>mO(t.text,t.source,r,{stripAgentPart:n,placeholders:!0,searchKeywords:t.searchKeywords}),[n,t.text,t.source,r,t.searchKeywords]);return t.source==="gpt"&&!n?null:(0,$o.jsxs)("div",{className:a.root,children:[(0,$o.jsx)(oe,{ref:l,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:gO,children:(0,$o.jsx)(rs,{containerTagName:"div",noWrap:!1,tagName:"span",className:a.formattedText,content:u})}),e&&o&&(0,$o.jsx)("div",{className:a.actions,children:(0,$o.jsx)(Kd,{source:"overlay",context:i,suggestion:t})})]})},$b=hO;var Vh=w(b()),yO=({suggestions:e,selectedIndex:t,reverse:n})=>{let r=(0,Gd.useMemo)(()=>{let o=e.map((i,s)=>(0,Vh.jsx)($b,{index:s,selected:s===t,suggestion:i},`${i.text}-${i.source}`));return n?o.reverse():o},[e,t,n]);return(0,Vh.jsx)(Gd.Fragment,{children:r})},Xd=yO;var qb={root:"dd-PfvRI",paper:"dd-HYlyY"};var fl=w(b()),vO=({textSuggestions:e,selectedIndex:t})=>{let n=(0,Yd.useRef)(null),r=A("InlineSuggestionsOverlay",qb),o=M(Rn),i=X(),s=M(rt),a=M(Ji),l=M($d),u=V("showTextSuggestions");return Zr(()=>{setTimeout(()=>{i(Jr({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Yd.useEffect)(()=>{let c=n.current;if(!c||!c.parentElement)return;c.parentElement.style.left="0px";let m=c.getBoundingClientRect();c.parentElement.style.left=`${Math.min(window.innerWidth-4-m.right,0)}px`}),l||!o||!u||e.length===0||s!==!0||a===!1?null:(0,fl.jsx)("div",{className:r.root,"data-variant":"inline",children:(0,fl.jsx)("div",{ref:n,className:r.paper,children:(0,fl.jsx)(mt,{children:(0,fl.jsx)(Xd,{suggestions:e,selectedIndex:t})})})})},SO=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),Gb=$n(SO)(vO);var pl=w(b()),wO=({children:e})=>{let n=V("locale").replace("-","");return(0,pl.jsx)(dh.Provider,{value:n,children:e})},xO=({store:e,customStyles:t={},children:n})=>(0,pl.jsx)(Wg,{store:e,children:(0,pl.jsx)(wO,{children:(0,pl.jsx)(Ls.Provider,{value:t,children:n})})}),qo=xO;var Zd=w(ie()),ms=w(H());var Xb=w(H());function Yb(e,t){let[n,r]=(0,Xb.useState)(()=>{if(typeof window=="undefined")return t;try{let i=window.localStorage.getItem(e);return i?JSON.parse(i):t}catch(i){return z.error(i),t}});return[n,i=>{try{let s=i instanceof Function?i(n):i;r(s),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(s))}catch(s){z.error(s)}}]}var Qb=()=>/Mac/i.test(navigator.platform);var Jb=w(ie()),ir=w(H());var Kh={};$e(Kh,{enUS:()=>EO,nlNL:()=>bO});var EO={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"}]}]},bO={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 Zb={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var eo=w(b()),Wh=(e,t,n)=>r=>(0,eo.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),CO=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let i=q(Kh),s=Wt(),a=A("Login",Zb),l=V("productName"),u=(0,ir.useCallback)(g=>{g.preventDefault(),r&&r(parseInt(g.target.value,10))},[]),c=(0,ir.useCallback)(g=>{g.preventDefault(),s.send(ns,!0)},[t]),m=(0,ir.useMemo)(()=>g=>(0,eo.jsx)("a",{onClick:h=>{h.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:g},"login"),[t]),d=(0,ir.useCallback)(g=>(0,eo.jsx)("button",{type:"button",className:a.anchorButton,onClick:c,children:g},"prompt"),[c]),{min:f,hour:v,day:y}=(0,ir.useMemo)(()=>({min:Wh(a,60*10,u),hour:Wh(a,60*60,u),day:Wh(a,60*60*12,u)}),[]);return(0,eo.jsxs)("div",{className:(0,Jb.default)(e,a.root),children:[i("loginPlease",{login:n?d:m,productName:l}),r&&(0,eo.jsxs)(ir.Fragment,{children:[(0,eo.jsx)("br",{}),i("snooze",{min:f,hour:v,day:y})]})]})},Qd=CO;var eC={root:"dd-DoQhb",text:"dd-Jwnev"};var ml=w(b()),TO=({title:e})=>{let t=A("SearchTrigger",eC),n=X();return(0,ml.jsxs)("button",{type:"button",className:t.root,onClick:()=>n(Ct(!0)),children:[(0,ml.jsx)(ss,{}),(0,ml.jsx)("span",{className:t.text,children:e})]})},tC=TO;var $h={};$e($h,{enUS:()=>kO,nlNL:()=>PO});var kO={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"}]},PO={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 nC={root:"dd-oa7Vc",isInline:"dd-bwk31",toggleButton:"dd-MSB8Z",toggleButtonWrapper:"dd-ZkCzT",toggleButtonWrapperHidden:"dd-Sq66c",isCollapsed:"dd-vkrPk",collapsible:"dd-CWQJe",hints:"dd-IOoo3",hintsHidden:"dd-psVuT",triggers:"dd-toIoo",triggersRight:"dd-mc4l2"};var be=w(b()),RO=({textSuggestions:e,selectedIndex:t,onLogIn:n})=>{let r=A("SuggestionsOverlay",nC),o=q($h),i=M(Rn),s=T1(),a=X(),l=(0,ms.useRef)(null),u=V("searchTriggerKey"),c=V("productName"),m=M($d),d=M(rt),f=M(Ji),[v,y]=(0,ms.useState)(null),g=V("showSearch"),p=V("showTextSuggestions"),h=V("adminUrl"),S=V("isEmbedded"),[x,T]=Yb("dd-snooze-until-ms",0),C=m||x>Date.now(),R=e.filter(D=>D.source!=="gpt").length,N=()=>{C&&T(0),a(Bb(!C))},_=D=>{let G=Date.now()+D*1e3;T(G),z.info(`Snooze until: ${new Date(G)}`),a(Jr({collapse:!0}))};return(0,ms.useEffect)(()=>{R===0&&y(null)},[e,R]),Zr(()=>{a(Jr({collapse:!0,skipWhenInputFocus:!0}))}),d===null||f===!1?null:d===!1?(0,be.jsxs)("div",{ref:l,className:(0,Zd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1}}),(0,be.jsx)("div",{className:r.triggersRight,children:(0,be.jsx)(po,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(po,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),(0,be.jsx)("div",{className:r.collapsible,children:(0,be.jsx)(Qd,{loginUrl:h,isEmbedded:S,onLogIn:n,onSnooze:_})})]}):!s||!i?null:(0,be.jsxs)("div",{ref:l,className:(0,Zd.default)(r.root,{[r.isCollapsed]:C}),children:[!C&&(0,be.jsxs)("div",{className:r.triggers,children:[(0,be.jsx)("div",{style:{flex:1},children:g&&(0,be.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>y(o(Qb()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>y(null),children:(0,be.jsx)(tC,{title:o("search")})})}),(0,be.jsxs)("div",{className:r.triggersRight,onFocus:()=>{},children:[(0,be.jsx)("div",{className:(0,Zd.default)(!v&&r.hintsHidden,r.hints),children:v}),(0,be.jsx)(po,{className:r.toggleButton,title:o("collapse"),onClick:N,isCollapsed:!1})]})]}),(0,be.jsx)("div",{className:r.toggleButtonWrapper,children:(0,be.jsx)(po,{className:r.toggleButton,title:o("open",{productName:c}),onClick:N,isCollapsed:!0})}),R>0&&p&&(0,be.jsx)("div",{className:r.collapsible,onFocus:()=>{},children:(0,be.jsx)(mt,{children:(0,be.jsx)(Xd,{suggestions:e,selectedIndex:t,reverse:!0})})})]})},AO=({input:e})=>({selectedIndex:e.selectedSuggestionIndex,textSuggestions:e.textSuggestions}),rC=$n(AO)(RO);var mf=w(ie());var ur=w(H());var gs=w(H());function Jd(e){return e.contentEditable==="true"}function LO(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),i=o.cloneRange();i.selectNodeContents(e),i.setEnd(o.endContainer,o.endOffset),n=i.toString().length,i.selectNodeContents(e),i.setEnd(o.startContainer,o.startOffset),t=i.toString().length}return{selectionStart:t,selectionEnd:n}}function oC(e){let{selectionStart:t,selectionEnd:n}=Jd(e)?LO(e):e;return[t,n]}function iC(e){let[,t]=(0,gs.useState)(),n=(0,gs.useRef)(null);return n.current=oC(e),(0,gs.useEffect)(()=>{let r=()=>{var a;let[o,i]=(a=n.current)!=null?a:[],s=oC(e);(!s||o!==s[0]||i!==s[1])&&(n.current=s,t({}))};return e.addEventListener("keyup",r),e.addEventListener("click",r),e.addEventListener("focus",r),document.addEventListener("selectionchange",r),()=>{e.removeEventListener("keyup",r),e.removeEventListener("click",r),e.removeEventListener("focus",r),document.removeEventListener("selectionchange",r)}},[e]),n.current}function sC(e,t){if(!t)return;let n=e,{value:r}=n,[o,i]=t,s=r.match(tu);if(!s||s.length===0)return;let a=0;s.find(l=>{let u=r.indexOf(l,a);return o>u&&i<u+l.length?(n.selectionStart=u,n.selectionEnd=u+l.length,!0):(a=u+l.length,!1)})}var aC=w(H()),IO=["div","span","mark","strong","b","i","u","em"];function qh(e,t,n=0){var i;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(i=r.props)==null?void 0:i.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(IO.includes(o)){let s=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,aC.cloneElement)(r,{children:qh(s,t,n+1)})]}return[...e,...t]}function to(e){return e.tagName.toLowerCase()==="textarea"}var lC={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var vC=w(ie());var uf=w(H());var hs=w(H());function uC(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function ef(e){let t=(0,hs.useRef)(null),[n,r]=(0,hs.useState)(!1);return(0,hs.useEffect)(()=>{var c;let o=!1,i=parseFloat((c=window.getComputedStyle(document.body).zoom)!=null?c:"1"),[s,a]=uC((m,d)=>{let f=t.current;if(!f)return;let v=m/i,y=d/i,g=f.getBoundingClientRect(),p=v>g.x&&v<g.x+g.width&&y>g.y&&y<g.y+g.height;p&&!o?(o=!0,r(!0)):!p&&o&&(o=!1,r(!1))},({clientX:m,clientY:d})=>[m,d]),[l,u]=uC(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",s),e.addEventListener("mouseleave",l),()=>{a(),u(),e.removeEventListener("mousemove",s),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function cC(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function tf(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function dC(e){return e!=null}var Xh=w(ie()),qt=w(H());var nf=w(H()),NO=["bottom","height","left","right","top","width"],OO=(e={},t={})=>NO.some(n=>e[n]!==t[n]),sr=new Map,fC,pC=()=>{let e=[],t=[];sr.forEach((n,r)=>{if(r instanceof Element&&!r.isConnected){t.push(r);return}let o=r.getBoundingClientRect();OO(o,n.rect)&&(n.rect=o,e.push(n))}),t.forEach(n=>{sr.delete(n)}),e.forEach(n=>{n.callbacks.forEach(r=>r(n.rect))}),fC=window.requestAnimationFrame(pC)};function MO(e,t){return{observe(){let n=sr.size===0;if(sr.has(e)){let r=sr.get(e);r.callbacks.push(t),r.rect&&t(r.rect)}else sr.set(e,{rect:void 0,hasRectChanged:!1,callbacks:[t]});n&&pC()},unobserve(){let n=sr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||sr.delete(e),sr.size||cancelAnimationFrame(fC)}}}}function Gh(e){let[t,n]=(0,nf.useState)(null);return(0,nf.useLayoutEffect)(()=>{if(!e.current)return;let r=MO(e.current,o=>{n(o)});return r.observe(),()=>{r.unobserve()}},[e]),t}var ys=w(H()),gC=w(gc());var mC={root:"dd-r-dgo"};var hC=({children:e,parentNode:t})=>{let[n,r]=(0,ys.useState)(null),o=(0,ys.useContext)(Ls);return(0,ys.useLayoutEffect)(()=>{let i=document.createElement("div");return Wo(i),i.classList.add(mC.root),o!=null&&o.portalRootNode&&i.classList.add(o==null?void 0:o.portalRootNode),(t||document.body).appendChild(i),r(i),()=>{i.isConnected&&i.remove()}},[]),n?(0,gC.createPortal)(e,n):null};var An={ref:"dd-iz-KP",root:"dd-vEMon",positionAbove:"dd-mUCxM",positionBelow:"dd-7oZI7",positionLeft:"dd-BiWvD",positionRight:"dd-JIWea",alignStart:"dd-5ivu6",alignCenter:"dd-rnVkP",alignEnd:"dd-gZBp4"};var rf=w(b()),of=(e=!1)=>{let[t,n]=(0,qt.useState)(e),r=(0,qt.useCallback)(()=>n(!0),[]),o=(0,qt.useCallback)(()=>n(!1),[]),i=(0,qt.useCallback)(()=>n(a=>!a),[]),s=(0,qt.useRef)(null);return{opened:t,open:r,close:o,toggle:i,triggerRef:s}};function Yh(e,t=null,n=0){if(!e)return{display:"none"};let r=t?e.top-t.top<0||e.top<t.top-n?t.top-n:e.top+e.height>t.top+t.height+n?t.top+t.height+n-e.height:e.top:e.top,o=t?e.left<t.left-n?t.left-n:e.left+e.width>t.left+t.width+n?t.left+t.width+n-e.width:e.left:e.left;return{top:r,left:o,height:e.height,width:e.width}}var vs=u=>{var c=u,{className:e,triggerRef:t,boundaryRef:n=(0,qt.createRef)(),position:r="above",align:o="center",children:i,toStyle:s=Yh,parentNode:a}=c,l=te(c,["className","triggerRef","boundaryRef","position","align","children","toStyle","parentNode"]);let m=Gh(t),d=Gh(n),f=(0,qt.useMemo)(()=>s(m,d,0),[m,d]);return(0,rf.jsx)(hC,{parentNode:a,children:(0,rf.jsx)("div",O(P({className:(0,Xh.default)(An.ref,{[An.positionAbove]:r==="above",[An.positionBelow]:r==="below",[An.positionLeft]:r==="left",[An.positionRight]:r==="right",[An.alignStart]:o==="start",[An.alignCenter]:o==="center",[An.alignEnd]:o==="end"}),style:f},l),{role:"dialog",children:(0,rf.jsx)("div",{className:(0,Xh.default)(e,An.root),children:i})}))})};var yC=w(ie()),sf=w(H());var ar={root:"dd-7-cgW",container:"dd-PsRQ8",agentText:"dd-qnW-V",tabText:"dd-cUHUr",hint:"dd-v7fSg",matchSelection:"dd-8cr8y",focus:"dd-3tr9l",resetIndent:"dd-TvQfZ",matchKeyword:"dd-oJkRD",matchPlaceholder:"dd-QvNoo",hover:"dd--wi0R",hintText:"dd-7gQQh",popover:"dd-xbRu-",popoverRoot:"dd-rA2x8",popoverContentContainer:"dd-JHICl",popoverContent:"dd--mfkC",selectionOptions:"dd-p52wn",selectionOptionsIsHidden:"dd-sSTDp",selectionOptionsButton:"dd-Q6kRY",caret:"dd-jIhc8",popoverSuggestionsRoot:"dd-iFDbL",suggestionsOverlayInputStyles:"dd-zzENA"};var Qh=w(b()),af=(0,sf.forwardRef)((o,r)=>{var i=o,{className:e,children:t}=i,n=te(i,["className","children"]);let s=(0,sf.useRef)(null),a=A("TabCompletion",ar);return(0,Qh.jsx)("div",O(P({ref:tf([s,r]),className:(0,yC.default)(e,a.popoverContentContainer)},n),{children:(0,Qh.jsx)("div",{className:a.popoverContent,children:t})}))});var no=w(b()),_O=e=>t=>{let n=Yh(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},DO=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let i=A("TabCompletion",ar),s=of(),a=(0,uf.useMemo)(()=>_O(e.getBoundingClientRect()),[e]),[l,u]=ef(e);return(0,uf.useEffect)(()=>{u?s.open():s.close()},[u]),(0,no.jsxs)("span",{children:[(0,no.jsx)("mark",{ref:tf([l,s.triggerRef]),className:(0,vC.default)(i.matchKeyword,{[i.hover]:u}),"aria-haspopup":"dialog","aria-expanded":s.opened?"true":"false",children:r}),s.opened&&(0,no.jsx)(vs,{className:i.popover,triggerRef:s.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,no.jsx)(af,{style:n,children:(0,no.jsx)("div",{className:i.hintText,children:o})})})]})},lf=class extends Zn{constructor(){super(...arguments);this.keywordMatches=[];this.preparedKeywordMatches=[];this.usedKeywordMatches=new Set}onBeforeParse(n,r){return r.keywordMatches&&r.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=r.keywordMatches.map(o=>O(P({},o),{keywordRegex:new RegExp(`\\b${cC(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(i=>{if(this.usedKeywordMatches.has(i))return null;let s=n.match(i.keywordRegex);if(!s)return null;let a=n.charAt(s.index-1),l=n.charAt(s.index+i.keyword.length);return a==="{"&&l==="}"?null:{index:s.index,length:s[0].length,match:s[0],matchString:s[0],suggestion:i.suggestion,preparedKeywordMatch:i,valid:!0}}).filter(dC);if(r.length===0)return null;let o=r.reduce((i,s)=>s.index<i.index?s:i);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,no.jsx)(DO,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var SC=w(ie());var Zh=w(b()),FO=({inputElement:e,children:t})=>{let n=A("TabCompletion",ar),[r,o]=ef(e);return(0,Zh.jsx)("mark",{ref:r,className:(0,SC.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},cf=class extends Zn{match(t){let n=t.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(t,n){return(0,Zh.jsx)(FO,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var ff=w(ie());var at=w(H());var Jh=w(b()),wC=()=>(0,Jh.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,Jh.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 ro=w(H());var EC=w(hh());var xC={root:"dd-ky-Bv",content:"dd-kV5e1"};function df(e,t,n){var o;let r=((o=e.imageSizes)==null?void 0:o[t])||e.image||n;if(!r)return null;try{return new URL(r).toString()}catch(i){return null}}function ey(e){return e.replace("https://www.","").replace("https://","")}var Gt=w(b()),HO=3,UO=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),zO=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=HO})=>{let i=A("LinkSearch",xC),[s,a]=(0,ro.useState)(""),l=X(),u=M(vb("url")),c=M($1("URL",UO)),[m,d]=(0,ro.useState)(c.length-1),f=V("fallbackImage"),v=h=>{let S=h.target;a(S.value)},y=(h,S)=>{h.stopPropagation(),h.preventDefault(),window.open(S,"_blank")},g=h=>{var T;let S=m-1<0?c.length-1:m-1,x=m+1===c.length?0:m+1;h.code==="Escape"&&(a(""),t()),h.code==="ArrowUp"&&d(S),h.code==="ArrowDown"&&d(x),h.code==="Enter"&&e(((T=c[m])==null?void 0:T.text)||s)},p=(0,ro.useCallback)((0,EC.default)(h=>{l(No({query:h,type:"URL",tags:["link-search"]}))},300),[]);return(0,ro.useEffect)(()=>{s&&p(s)},[s]),(0,ro.useEffect)(()=>()=>{l(ud())},[]),(0,Gt.jsxs)("div",{className:i.root,children:[(0,Gt.jsx)(mt,{withDivider:!0,children:(s?c:u).slice(0,o).map((h,S)=>(0,Gt.jsx)(oe,{selected:m===S,onClick:()=>e(h.text),"data-testid":"linksearch-suggestion",children:(0,Gt.jsxs)(ye,{children:[(0,Gt.jsx)(ye.Image,{src:df(h,"small",f||void 0),title:h.title||h.text}),(0,Gt.jsxs)(ye.Content,{className:i.content,cropText:!0,children:[(0,Gt.jsx)(ye.Title,{children:h.title||ey(h.text)}),h.title&&ey(h.text)]}),(0,Gt.jsx)(oe.Actions,{children:(0,Gt.jsx)(oe.ActionButton,{label:r,onClick:x=>y(x,h.text)})})]})},h.text))}),(0,Gt.jsx)(Ga,{value:s,onChange:v,autoFocus:!0,placeholder:n,onKeyUp:g})]})},bC=zO;var ty={};$e(ty,{enUS:()=>BO,nlNL:()=>jO});var BO={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},jO={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};var st=w(b()),VO=(0,at.forwardRef)((e,t)=>{let n=A("TabCompletion",ar);return(0,st.jsx)("mark",{ref:t,className:(0,ff.default)(n.matchSelection)},"selection-start")}),KO=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let i=q(ty),s=A("TabCompletion",ar),a=(0,at.useRef)(null),l=(0,at.useRef)(null),[u,c]=(0,at.useState)(null),m=X(),d=of(document.activeElement===r),[f]=(0,at.useState)(()=>document.createRange());d.triggerRef.current=f,(0,at.useEffect)(()=>()=>f.detach(),[]),(0,at.useEffect)(()=>{let y=e.current,g=a.current;!y||!g||(f.setStart(y,0),f.setEnd(g,0))},[e.current,a.current]),Zr(()=>{d.close()});let v=(0,at.useCallback)(y=>{let g=f.toString(),p=/^http(s?):\/\//.test(y)?y:`https://${y}`;m(rd({text:`[${g}](${p})`,replace:"selection"}))},[]);return(0,st.jsxs)("span",{children:[(0,st.jsx)("mark",{ref:a,className:(0,ff.default)(s.matchSelection),"aria-haspopup":"dialog","aria-expanded":d.opened?"true":"false",children:o}),d.opened&&(0,st.jsx)(vs,{className:s.popoverRoot,triggerRef:d.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,st.jsxs)(af,{style:n,ref:l,children:[(0,st.jsx)("div",{className:(0,ff.default)(s.selectionOptions,{[s.selectionOptionsIsHidden]:u!==null}),children:(0,st.jsxs)("button",{type:"button",tabIndex:u===null?-1:void 0,className:s.selectionOptionsButton,onClick:()=>c("insertLink"),children:[(0,st.jsx)(wC,{}),(0,st.jsx)("span",{children:"\xA0"}),(0,st.jsx)("span",{children:i("insertLink")})]})}),u==="insertLink"&&(0,st.jsx)(bC,{placeholder:i("linkInputPlaceholder"),visitUrlText:i("visitUrl"),onSelectLink:v,onDismiss:()=>{c(null),d.close()}})]})})]},"selection-end")},pf=class extends Zn{constructor(){super(...arguments);this.charCount=0;this.foundIndex=0;this.startRef=null}onBeforeParse(n,r){return this.props=r,this.charCount=0,this.startRef=(0,at.createRef)(),this.foundIndex=0,n}match(n){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[r,o]=this.props.selection;if(r===o)return null;let i=this.foundIndex===0?r:o,s=i>=this.charCount&&i<=this.charCount+n.length?{index:i-this.charCount,length:0,match:"",valid:!0}:null;s&&this.foundIndex++;let a=this.foundIndex===1;return s&&a?this.charCount+=i-this.charCount:this.charCount+=n.length,s?P({isStart:a},s):null}replaceWith(n,r){return r.isStart?(0,st.jsx)(VO,{ref:this.startRef}):(0,st.jsx)(KO,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var lr=w(b()),WO=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:i,keywordMatches:s,inputElement:a,source:l})=>{let u=A("TabCompletion",lC),c=V("insertLink"),m=V("showMidSentenceSuggestions"),d=V("inlineSuggestions"),f=iC(a),v=(0,ur.useRef)(null),y=M(rt);(0,ur.useEffect)(()=>{to(a)&&f&&sC(a,f)},[f]);let g=(0,ur.useCallback)(S=>{if(!o||!n)return S;let x=[(0,lr.jsx)("span",{className:u.resetIndent,children:"\u200B"},"u200B"),(0,lr.jsx)("span",{"data-testid":"tab-completion",className:(0,mf.default)(u.tabText,u.resetIndent),"data-source":l,children:n},"tabText")];return r&&x.push((0,lr.jsx)("span",{className:(0,mf.default)(u.hint,u.resetIndent),children:(0,lr.jsx)(Ql,{keyCode:"tab"},"tabHint")})),qh(S,x)},[o,n,r]),p=(0,ur.useMemo)(()=>{let S=[];return c&&S.push(new pf("selection")),S.push(new cf("placeholders")),i&&S.push(new lf("keywords")),S},[d,c,i]),h=(0,ur.useMemo)(()=>{let S=window.getComputedStyle(a);return{"--dd-color":S.color,"--dd-font-size":S.fontSize,"--dd-font-family":S.fontFamily,"--dd-font-variant":S.fontVariant}},[]);return!e||!y?null:(0,lr.jsxs)("div",{ref:S=>{S!=null&&S.parentElement&&(v.current=S==null?void 0:S.parentElement)},className:u.root,style:h,children:[(0,lr.jsx)(rs,{tagName:"span",containerTagName:"div",className:(0,mf.default)(u.container,u.agentText),disableLineBreaks:to(a),content:t||"\u200B",onAfterParse:g,matchers:p,selection:f,keywordMatches:s,inputElement:a,inputStyle:h,boundaryRef:v,inlineSuggestionsOnlyAtEnd:!m}),(0,lr.jsx)("br",{})]})},$O=e=>{var g,p,h;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:i}=e,s=ts({input:t}),a=(s==null?void 0:s.text)||"",l=(s==null?void 0:s.source)||"",u=(g=t.html)!=null?g:os(t.text),c=a.indexOf(t.text)===0?a.slice(t.text.length):"",{showTabHint:m}=n,{isSupported:d}=i,{showTabCompletion:f,visible:v,showStyleSuggestions:y}=r;return{showTabHint:m,showStyleSuggestions:y,showTabCompletion:f&&Rn(e),content:u,tabText:c,source:l,keywordMatches:(h=(p=o.list)==null?void 0:p.keywordMatches)!=null?h:[],enabled:v&&d!==!1}},CC=$n($O)(WO);var UT=w(ie()),Pl=w(H());var TC={list:[],fetchState:"idle"},PC=e=>e.autoflows.list||[],kC=e=>t=>{var n;return(n=t.list)==null?void 0:n.find(r=>r.triggerPayload===e)},cr=K("autoflows/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(e)})),ny=K("autoflows/start",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.startAutoflowSession(e),yield n(cr(e.platformSessionId))})),ry=K("autoflows/stop",(e,t)=>k(void 0,null,function*(){let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");yield r.stopAutoflowSession(e.platformSessionId),yield n(cr(e.platformSessionId))})),qO=Q({name:"autoflows",initialState:TC,reducers:{},extraReducers:e=>{e.addCase(ny.pending,(t,n)=>{let r=kC(n.meta.arg.triggerPayload)(t);r.state="Started",r.isBusy=!0}),e.addCase(ry.pending,(t,n)=>{let r=kC(n.meta.arg.triggerPayload)(t);r.state="Aborted",r.isBusy=!0}),e.addCase(cr.pending,t=>{t.fetchState="loading"}),e.addCase(cr.rejected,t=>{t.fetchState="error"}),e.addCase(cr.fulfilled,(t,n)=>{t.list=n.payload,t.fetchState="done"}),e.addCase(fe,()=>TC)}}),RC=K("autoflows/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");let o=r.openStream(e);o.on("sessionAborted",()=>{n(cr(e))}),o.on("sessionCompleted",()=>{n(cr(e))})}),AC=K("autoflows/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),LC=qO.reducer;var IC={list:[],fetchState:"idle",sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},NC=e=>e.customMessages.list,OC=e=>t=>!!t.customMessages.sentSuggestions.find(n=>n===e),MC=e=>t=>!!t.customMessages.answeredSuggestions.find(n=>n===e),_C=e=>t=>!!t.customMessages.errorSuggestions.find(n=>n===e),gl=K("customMessages/getAll",(e,t)=>k(void 0,null,function*(){let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(e)})),gf=K("customMessages/send",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,suggestion:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.sendCustomMessage(n,r)})),hf=K("customMessages/answer",(e,t)=>k(void 0,null,function*(){let{platformSessionId:n,reply:r}=e,{deepdeskBrokerAPI:o}=t.extra;if(!o)throw new Error("Deepdesk Broker not initialized");yield o.answerCustomMessage(n,r)})),DC=Q({name:"customMessages",initialState:IC,reducers:{onCustomMessage(e,t){Array.isArray(t.payload)?e.list=t.payload:e.list=[t.payload]}},extraReducers:e=>{e.addCase(gl.pending,t=>{t.fetchState="loading"}).addCase(gl.rejected,t=>{t.fetchState="error"}).addCase(gl.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload||[]}).addCase(gf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.errorSuggestions=t.errorSuggestions.filter(r=>n.meta.arg.suggestion.text!==r)}).addCase(gf.rejected,(t,n)=>{let r=t.sentSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1))}).addCase(hf.pending,(t,n)=>{t.sentSuggestions.push(n.meta.arg.suggestion.text),t.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(hf.rejected,(t,n)=>{let r=t.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);t.errorSuggestions.push(...t.sentSuggestions.splice(r,1)),t.answeredSuggestions.splice(r,1)}).addCase(fe,()=>IC)}}),FC=K("customMessages/openStream",(e,t)=>{let{dispatch:n}=t,{deepdeskBrokerAPI:r}=t.extra;if(!r)throw new Error("Deepdesk Broker not initialized");r.openStream(e).on("customMessageSuggestion",i=>{n(DC.actions.onCustomMessage(i))})}),HC=K("customMessages/closeStream",(e,t)=>{let{deepdeskBrokerAPI:n}=t.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(e)}),UC=DC.reducer;var GO={token:null,interval:null},oy=K("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>k(void 0,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),iy=K("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(oy()),setInterval(()=>r(oy()),n)}),zC=Q({name:"passwordlessToken",initialState:GO,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(oy.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(iy.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:BC}=zC.actions,jC=zC.reducer;var VC={shouldEmit:!0},sy={cues:[],fetchState:"idle"},KC=e=>{var t;return(t=e.rules)==null?void 0:t.cues},XO=Re("rules/resetCues"),Go=K("rules/evaluate",(e,t)=>k(void 0,null,function*(){var n,r;try{let{deepdeskAPI:o}=t.extra,i=t.getState(),s=(n=i.conversation.current)==null?void 0:n.id;if(!s)throw new Error("No current conversation to evaluate rules");if(!(yield o.getAccount()).ruleEngine)throw new Error("Rule engine is not enabled for this account");if(!(yield o.getRules()).filter(m=>m.isEnabled).some(m=>m.label===e.label))throw new Error(`No enabled rules found with label: ${e.label}`);return{cues:yield o.evaluateRule(e.label,s,P({tags:((r=i.conversation.current)==null?void 0:r.tags)||void 0},e.params)),options:e.options}}catch(o){let i=o.message;return z.warn(i),t.rejectWithValue(i)}})),WC=Q({name:"answer",initialState:sy,reducers:{removeCue(e,t){e.cues=e.cues.filter(n=>n.rule.id!==t.payload.id)}},extraReducers:e=>{e.addCase(Go.pending,t=>{t.fetchState="loading"}).addCase(Go.rejected,t=>{t.fetchState="error"}).addCase(Go.fulfilled,(t,n)=>{let r=n.payload.cues.map(i=>i.rule.id),o=t.cues.filter(i=>!r.includes(i.rule.id));t.fetchState="done",t.cues=[...n.payload.cues,...o]}).addCase(fe,()=>sy).addCase(XO.toString(),()=>sy)}}),{removeCue:$C}=WC.actions,qC=WC.reducer;var nT=w(H());var JC=w(ie()),eT=w(H());var XC=w(ie());var GC={root:"dd-uszkm"};var QC=w(b()),YO=({className:e,children:t})=>{let n=A("Unicode",GC);return(0,QC.jsx)("span",{className:(0,XC.default)(e,n.root),children:t})},YC=YO;var ZC={isDisabled:"dd-Sp--t",root:"dd-maqTG",buttonStop:"dd-rcq8w",stateBadge:"dd-zOnkT",isCompleted:"dd-GA-rt",isStarted:"dd-PZwtX",isAborted:"dd-PAXSE"};var ay={};$e(ay,{enUS:()=>QO,nlNL:()=>ZO});var QO={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"}]},ZO={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 Rt=w(b()),eM=({disabled:e,state:t,displayName:n,description:r,onStartAutoflow:o,onStopAutoflow:i})=>{let s=A("Autoflow",ZC),a=q(ay),l=t==="Started"?"stop":"start",u=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return(0,Rt.jsxs)(oe,{className:(0,JC.default)(s.root,{[s.isDisabled]:e,[s.isCompleted]:t==="Completed",[s.isAborted]:t==="Aborted",[s.isStarted]:t==="Started"}),children:[(0,Rt.jsx)(ye,{children:(0,Rt.jsxs)(ye.Content,{children:[(0,Rt.jsxs)(ye.Title,{children:[t&&(0,Rt.jsx)("span",{className:s.stateBadge,children:a(t)}),n]}),(0,Rt.jsx)("span",{children:r})]})}),(0,Rt.jsx)(oe.Actions,{fixed:t==="Started",children:(0,Rt.jsx)(oe.ActionButton,{primary:!0,className:l==="start"?s.buttonStart:s.buttonStop,onClick:t==="Started"?i:o,disabled:e,label:(0,Rt.jsxs)(eT.Fragment,{children:[(0,Rt.jsx)(YC,{children:u})," ",(0,Rt.jsx)("span",{children:a(l)})]})})})]})},tT=eM;var ly=w(b()),tM=(e,t)=>{let n=t.filter(r=>r.state==="Started");return n.length>0?n.indexOf(e)===-1:!1},nM=({autoflows:e,onStartAutoflow:t,onStopAutoflow:n,platformSessionId:r})=>(0,ly.jsx)(nT.Fragment,{children:e.map(o=>(0,ly.jsx)(tT,{displayName:o.displayName,description:o.description,disabled:o.isBusy||tM(o,e),state:o.state,onStartAutoflow:()=>t({platformSessionId:r,triggerPayload:o.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:r,triggerPayload:o.triggerPayload})},o.displayName))}),rM=({autoflows:e,conversation:t})=>{var n;return{autoflows:e.list,platformSessionId:(n=t.current)==null?void 0:n.sessionId}},oM={onStartAutoflow:ny,onStopAutoflow:ry},rT=$n(rM,oM)(nM);var oT=w(ie()),uy=w(H());var dr={root:"dd-ERsBr",title:"dd-b36p6",isUsed:"dd-fp2IX",quickReplies:"dd--VrvP",quickReply:"dd-wFhWh",label:"dd-R9sND",errorIcon:"dd-8cdcH"};var St=w(b()),iM=({suggestion:e})=>{let t=q(Vo),n=X(),r=M(OC(e.text)),o=M(MC(e.text)),i=M(_C(e.text)),s=M(Zi),{replyOptions:a}=e,l=(0,uy.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),!(r||!s)&&n(gf({platformSessionId:s,suggestion:e}))},[e,r,n,s]),u=(0,uy.useCallback)(c=>{if(c.preventDefault(),c.stopPropagation(),!s||!a)return;let m=parseInt(c.target.dataset.index,10),d=a[m];n(hf({platformSessionId:s,reply:d,suggestion:e}))},[e,r,n,s]);return(0,St.jsxs)(oe,{onClick:l,className:(0,oT.default)(dr.root,{[dr.isUsed]:r,[dr.hasError]:i}),children:[(0,St.jsx)(ye,{children:(0,St.jsxs)(ye.Content,{children:[(0,St.jsxs)(ye.Title,{className:dr.title,children:[e.text," ",(0,St.jsx)(Zl,{className:dr.label,children:"analyse tool"})," ",i&&(0,St.jsx)("span",{className:dr.errorIcon,role:"img","aria-label":t("sendingError"),title:t("sendingError"),children:"!"})]}),a&&a.length>0&&(0,St.jsx)("ul",{className:dr.quickReplies,children:a.map(c=>(0,St.jsx)("li",{className:dr.quickReply,children:c.title},c.title))})]})}),(0,St.jsxs)(oe.Actions,{fixed:i||r,children:[a&&a.length>0&&(0,St.jsx)(oe.DropdownButton,{label:t("answer"),disabled:o,children:a.map((c,m)=>(0,St.jsx)(oe.DropdownItem,{index:m,label:c.title,onClick:u},c.title))}),(0,St.jsx)(oe.ActionButton,{primary:!0,disabled:r,onClick:l,label:t(r?"suggestionSent":i?"tryAgain":"sendSuggestion")})]})]})},iT=iM;var yf=w(H());var dy=w(ie());var cy=w(b()),hl=()=>(0,cy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,cy.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 sT={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Ln=w(b()),sM=({entities:e})=>{let t=A("EntitiesWidgetList",sT),[n,r]=(0,yf.useState)(void 0),o=X(),i=()=>{r(void 0)},s=a=>{e&&(r(e.indexOf(a)),Yn(a.text),o(ot({name:"entity copied",data:{entity:a,type:"copy"}})))};return(0,yf.useEffect)(()=>{let a=setTimeout(i,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Ln.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Ln.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>s(a),children:[(0,Ln.jsx)("span",{className:t.entityText,children:a.text}),(0,Ln.jsxs)("span",{className:t.iconWrapper,children:[(0,Ln.jsx)("span",{className:(0,dy.default)(t.icon),children:(0,Ln.jsx)(hl,{})}),(0,Ln.jsx)("span",{className:(0,dy.default)(t.icon,n===l&&t.iconClicked),children:(0,Ln.jsx)(hl,{})})]})]},a.text))})},aT=sM;var fy=w(b()),lT=()=>(0,fy.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,fy.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 py=w(b()),uT=()=>(0,py.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,py.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 my=w(b()),cT=()=>(0,my.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:(0,my.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 AT=w(H());var yl=w(b()),dT=({className:e})=>(0,yl.jsxs)("svg",{viewBox:"0 0 12 12",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:e,children:[(0,yl.jsx)("line",{x1:"2",y1:"10",x2:"10",y2:"2",stroke:"black",strokeWidth:"1"}),(0,yl.jsx)("line",{x1:"2",y1:"2",x2:"10",y2:"10",stroke:"black",strokeWidth:"1"})]});var{entries:ST,setPrototypeOf:fT,isFrozen:aM,getPrototypeOf:lM,getOwnPropertyDescriptor:uM}=Object,{freeze:lt,seal:mn,create:wT}=Object,{apply:wy,construct:xy}=typeof Reflect!="undefined"&&Reflect;lt||(lt=function(t){return t});mn||(mn=function(t){return t});wy||(wy=function(t,n,r){return t.apply(n,r)});xy||(xy=function(t,n){return new t(...n)});var vf=Lt(Array.prototype.forEach),pT=Lt(Array.prototype.pop),vl=Lt(Array.prototype.push),xf=Lt(String.prototype.toLowerCase),gy=Lt(String.prototype.toString),cM=Lt(String.prototype.match),Sl=Lt(String.prototype.replace),dM=Lt(String.prototype.indexOf),fM=Lt(String.prototype.trim),pn=Lt(Object.prototype.hasOwnProperty),At=Lt(RegExp.prototype.test),wl=pM(TypeError);function Lt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return wy(e,t,r)}}function pM(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return xy(e,n)}}function ee(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xf;fT&&fT(e,null);let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let i=n(o);i!==o&&(aM(t)||(t[r]=i),o=i)}e[o]=!0}return e}function mM(e){for(let t=0;t<e.length;t++)pn(e,t)||(e[t]=null);return e}function Xo(e){let t=wT(null);for(let[n,r]of ST(e))pn(e,n)&&(Array.isArray(r)?t[n]=mM(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Xo(r):t[n]=r);return t}function Sf(e,t){for(;e!==null;){let r=uM(e,t);if(r){if(r.get)return Lt(r.get);if(typeof r.value=="function")return Lt(r.value)}e=lM(e)}function n(){return null}return n}var mT=lt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),hy=lt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),yy=lt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),gM=lt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),vy=lt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hM=lt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),gT=lt(["#text"]),hT=lt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),Sy=lt(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),yT=lt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),wf=lt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yM=mn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),vM=mn(/<%[\w\W]*|[\w\W]*%>/gm),SM=mn(/\${[\w\W]*}/gm),wM=mn(/^data-[\-\w.\u00B7-\uFFFF]/),xM=mn(/^aria-[\-\w]+$/),xT=mn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),EM=mn(/^(?:\w+script|data):/i),bM=mn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ET=mn(/^html$/i),vT=Object.freeze({__proto__:null,MUSTACHE_EXPR:yM,ERB_EXPR:vM,TMPLIT_EXPR:SM,DATA_ATTR:wM,ARIA_ATTR:xM,IS_ALLOWED_URI:xT,IS_SCRIPT_OR_DATA:EM,ATTR_WHITESPACE:bM,DOCTYPE_NAME:ET}),CM=function(){return typeof window=="undefined"?null:window},TM=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function bT(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:CM(),t=j=>bT(j);if(t.version="3.0.9",t.removed=[],!e||!e.document||e.document.nodeType!==9)return t.isSupported=!1,t;let{document:n}=e,r=n,o=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:s,Node:a,Element:l,NodeFilter:u,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:m,DOMParser:d,trustedTypes:f}=e,v=l.prototype,y=Sf(v,"cloneNode"),g=Sf(v,"nextSibling"),p=Sf(v,"childNodes"),h=Sf(v,"parentNode");if(typeof s=="function"){let j=n.createElement("template");j.content&&j.content.ownerDocument&&(n=j.content.ownerDocument)}let S,x="",{implementation:T,createNodeIterator:C,createDocumentFragment:R,getElementsByTagName:N}=n,{importNode:_}=r,D={};t.isSupported=typeof ST=="function"&&typeof h=="function"&&T&&T.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:G,ERB_EXPR:Z,TMPLIT_EXPR:se,DATA_ATTR:mr,ARIA_ATTR:It,IS_SCRIPT_OR_DATA:gr,ATTR_WHITESPACE:Nt}=vT,{IS_ALLOWED_URI:B}=vT,J=null,hr=ee({},[...mT,...hy,...yy,...vy,...gT]),we=null,yr=ee({},[...hT,...Sy,...yT,...wf]),Y=Object.seal(wT(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),vr=null,_l=null,ei=!0,ao=!0,Cs=!1,Dl=!0,Qt=!1,Zt=!1,Fl=!1,ut=!1,Ot=!1,Hl=!1,Ul=!1,Dy=!0,Fy=!1,Ik="user-content-",Of=!0,Ts=!1,ti={},ni=null,Hy=ee({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Uy=null,zy=ee({},["audio","video","img","source","image","track"]),Mf=null,By=ee({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zl="http://www.w3.org/1998/Math/MathML",Bl="http://www.w3.org/2000/svg",Mn="http://www.w3.org/1999/xhtml",ri=Mn,_f=!1,Df=null,Nk=ee({},[zl,Bl,Mn],gy),ks=null,Ok=["application/xhtml+xml","text/html"],Mk="text/html",De=null,oi=null,_k=n.createElement("form"),jy=function(E){return E instanceof RegExp||E instanceof Function},Ff=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(oi&&oi===E)){if((!E||typeof E!="object")&&(E={}),E=Xo(E),ks=Ok.indexOf(E.PARSER_MEDIA_TYPE)===-1?Mk:E.PARSER_MEDIA_TYPE,De=ks==="application/xhtml+xml"?gy:xf,J=pn(E,"ALLOWED_TAGS")?ee({},E.ALLOWED_TAGS,De):hr,we=pn(E,"ALLOWED_ATTR")?ee({},E.ALLOWED_ATTR,De):yr,Df=pn(E,"ALLOWED_NAMESPACES")?ee({},E.ALLOWED_NAMESPACES,gy):Nk,Mf=pn(E,"ADD_URI_SAFE_ATTR")?ee(Xo(By),E.ADD_URI_SAFE_ATTR,De):By,Uy=pn(E,"ADD_DATA_URI_TAGS")?ee(Xo(zy),E.ADD_DATA_URI_TAGS,De):zy,ni=pn(E,"FORBID_CONTENTS")?ee({},E.FORBID_CONTENTS,De):Hy,vr=pn(E,"FORBID_TAGS")?ee({},E.FORBID_TAGS,De):{},_l=pn(E,"FORBID_ATTR")?ee({},E.FORBID_ATTR,De):{},ti=pn(E,"USE_PROFILES")?E.USE_PROFILES:!1,ei=E.ALLOW_ARIA_ATTR!==!1,ao=E.ALLOW_DATA_ATTR!==!1,Cs=E.ALLOW_UNKNOWN_PROTOCOLS||!1,Dl=E.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Qt=E.SAFE_FOR_TEMPLATES||!1,Zt=E.WHOLE_DOCUMENT||!1,Ot=E.RETURN_DOM||!1,Hl=E.RETURN_DOM_FRAGMENT||!1,Ul=E.RETURN_TRUSTED_TYPE||!1,ut=E.FORCE_BODY||!1,Dy=E.SANITIZE_DOM!==!1,Fy=E.SANITIZE_NAMED_PROPS||!1,Of=E.KEEP_CONTENT!==!1,Ts=E.IN_PLACE||!1,B=E.ALLOWED_URI_REGEXP||xT,ri=E.NAMESPACE||Mn,Y=E.CUSTOM_ELEMENT_HANDLING||{},E.CUSTOM_ELEMENT_HANDLING&&jy(E.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=E.CUSTOM_ELEMENT_HANDLING.tagNameCheck),E.CUSTOM_ELEMENT_HANDLING&&jy(E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=E.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),E.CUSTOM_ELEMENT_HANDLING&&typeof E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=E.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Qt&&(ao=!1),Hl&&(Ot=!0),ti&&(J=ee({},gT),we=[],ti.html===!0&&(ee(J,mT),ee(we,hT)),ti.svg===!0&&(ee(J,hy),ee(we,Sy),ee(we,wf)),ti.svgFilters===!0&&(ee(J,yy),ee(we,Sy),ee(we,wf)),ti.mathMl===!0&&(ee(J,vy),ee(we,yT),ee(we,wf))),E.ADD_TAGS&&(J===hr&&(J=Xo(J)),ee(J,E.ADD_TAGS,De)),E.ADD_ATTR&&(we===yr&&(we=Xo(we)),ee(we,E.ADD_ATTR,De)),E.ADD_URI_SAFE_ATTR&&ee(Mf,E.ADD_URI_SAFE_ATTR,De),E.FORBID_CONTENTS&&(ni===Hy&&(ni=Xo(ni)),ee(ni,E.FORBID_CONTENTS,De)),Of&&(J["#text"]=!0),Zt&&ee(J,["html","head","body"]),J.table&&(ee(J,["tbody"]),delete vr.tbody),E.TRUSTED_TYPES_POLICY){if(typeof E.TRUSTED_TYPES_POLICY.createHTML!="function")throw wl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof E.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw wl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=E.TRUSTED_TYPES_POLICY,x=S.createHTML("")}else S===void 0&&(S=TM(f,o)),S!==null&&typeof x=="string"&&(x=S.createHTML(""));lt&&lt(E),oi=E}},Vy=ee({},["mi","mo","mn","ms","mtext"]),Ky=ee({},["foreignobject","desc","title","annotation-xml"]),Dk=ee({},["title","style","font","a","script"]),Wy=ee({},[...hy,...yy,...gM]),$y=ee({},[...vy,...hM]),Fk=function(E){let I=h(E);(!I||!I.tagName)&&(I={namespaceURI:ri,tagName:"template"});let U=xf(E.tagName),me=xf(I.tagName);return Df[E.namespaceURI]?E.namespaceURI===Bl?I.namespaceURI===Mn?U==="svg":I.namespaceURI===zl?U==="svg"&&(me==="annotation-xml"||Vy[me]):!!Wy[U]:E.namespaceURI===zl?I.namespaceURI===Mn?U==="math":I.namespaceURI===Bl?U==="math"&&Ky[me]:!!$y[U]:E.namespaceURI===Mn?I.namespaceURI===Bl&&!Ky[me]||I.namespaceURI===zl&&!Vy[me]?!1:!$y[U]&&(Dk[U]||!Wy[U]):!!(ks==="application/xhtml+xml"&&Df[E.namespaceURI]):!1},lo=function(E){vl(t.removed,{element:E});try{E.parentNode.removeChild(E)}catch(I){E.remove()}},Hf=function(E,I){try{vl(t.removed,{attribute:I.getAttributeNode(E),from:I})}catch(U){vl(t.removed,{attribute:null,from:I})}if(I.removeAttribute(E),E==="is"&&!we[E])if(Ot||Hl)try{lo(I)}catch(U){}else try{I.setAttribute(E,"")}catch(U){}},qy=function(E){let I=null,U=null;if(ut)E="<remove></remove>"+E;else{let We=cM(E,/^[\r\n\t ]+/);U=We&&We[0]}ks==="application/xhtml+xml"&&ri===Mn&&(E='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+E+"</body></html>");let me=S?S.createHTML(E):E;if(ri===Mn)try{I=new d().parseFromString(me,ks)}catch(We){}if(!I||!I.documentElement){I=T.createDocument(ri,"template",null);try{I.documentElement.innerHTML=_f?x:me}catch(We){}}let Ke=I.body||I.documentElement;return E&&U&&Ke.insertBefore(n.createTextNode(U),Ke.childNodes[0]||null),ri===Mn?N.call(I,Zt?"html":"body")[0]:Zt?I.documentElement:Ke},Gy=function(E){return C.call(E.ownerDocument||E,E,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null)},Hk=function(E){return E instanceof m&&(typeof E.nodeName!="string"||typeof E.textContent!="string"||typeof E.removeChild!="function"||!(E.attributes instanceof c)||typeof E.removeAttribute!="function"||typeof E.setAttribute!="function"||typeof E.namespaceURI!="string"||typeof E.insertBefore!="function"||typeof E.hasChildNodes!="function")},Xy=function(E){return typeof a=="function"&&E instanceof a},_n=function(E,I,U){D[E]&&vf(D[E],me=>{me.call(t,I,U,oi)})},Yy=function(E){let I=null;if(_n("beforeSanitizeElements",E,null),Hk(E))return lo(E),!0;let U=De(E.nodeName);if(_n("uponSanitizeElement",E,{tagName:U,allowedTags:J}),E.hasChildNodes()&&!Xy(E.firstElementChild)&&At(/<[/\w]/g,E.innerHTML)&&At(/<[/\w]/g,E.textContent))return lo(E),!0;if(!J[U]||vr[U]){if(!vr[U]&&Zy(U)&&(Y.tagNameCheck instanceof RegExp&&At(Y.tagNameCheck,U)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(U)))return!1;if(Of&&!ni[U]){let me=h(E)||E.parentNode,Ke=p(E)||E.childNodes;if(Ke&&me){let We=Ke.length;for(let ct=We-1;ct>=0;--ct)me.insertBefore(y(Ke[ct],!0),g(E))}}return lo(E),!0}return E instanceof l&&!Fk(E)||(U==="noscript"||U==="noembed"||U==="noframes")&&At(/<\/no(script|embed|frames)/i,E.innerHTML)?(lo(E),!0):(Qt&&E.nodeType===3&&(I=E.textContent,vf([G,Z,se],me=>{I=Sl(I,me," ")}),E.textContent!==I&&(vl(t.removed,{element:E.cloneNode()}),E.textContent=I)),_n("afterSanitizeElements",E,null),!1)},Qy=function(E,I,U){if(Dy&&(I==="id"||I==="name")&&(U in n||U in _k))return!1;if(!(ao&&!_l[I]&&At(mr,I))){if(!(ei&&At(It,I))){if(!we[I]||_l[I]){if(!(Zy(E)&&(Y.tagNameCheck instanceof RegExp&&At(Y.tagNameCheck,E)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(E))&&(Y.attributeNameCheck instanceof RegExp&&At(Y.attributeNameCheck,I)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(I))||I==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&At(Y.tagNameCheck,U)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(U))))return!1}else if(!Mf[I]){if(!At(B,Sl(U,Nt,""))){if(!((I==="src"||I==="xlink:href"||I==="href")&&E!=="script"&&dM(U,"data:")===0&&Uy[E])){if(!(Cs&&!At(gr,Sl(U,Nt,"")))){if(U)return!1}}}}}}return!0},Zy=function(E){return E!=="annotation-xml"&&E.indexOf("-")>0},Jy=function(E){_n("beforeSanitizeAttributes",E,null);let{attributes:I}=E;if(!I)return;let U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we},me=I.length;for(;me--;){let Ke=I[me],{name:We,namespaceURI:ct,value:uo}=Ke,Ps=De(We),dt=We==="value"?uo:fM(uo);if(U.attrName=Ps,U.attrValue=dt,U.keepAttr=!0,U.forceKeepAttr=void 0,_n("uponSanitizeAttribute",E,U),dt=U.attrValue,U.forceKeepAttr||(Hf(We,E),!U.keepAttr))continue;if(!Dl&&At(/\/>/i,dt)){Hf(We,E);continue}Qt&&vf([G,Z,se],tv=>{dt=Sl(dt,tv," ")});let ev=De(E.nodeName);if(Qy(ev,Ps,dt)){if(Fy&&(Ps==="id"||Ps==="name")&&(Hf(We,E),dt=Ik+dt),S&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ct)switch(f.getAttributeType(ev,Ps)){case"TrustedHTML":{dt=S.createHTML(dt);break}case"TrustedScriptURL":{dt=S.createScriptURL(dt);break}}try{ct?E.setAttributeNS(ct,We,dt):E.setAttribute(We,dt),pT(t.removed)}catch(tv){}}}_n("afterSanitizeAttributes",E,null)},Uk=function j(E){let I=null,U=Gy(E);for(_n("beforeSanitizeShadowDOM",E,null);I=U.nextNode();)_n("uponSanitizeShadowNode",I,null),!Yy(I)&&(I.content instanceof i&&j(I.content),Jy(I));_n("afterSanitizeShadowDOM",E,null)};return t.sanitize=function(j){let E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},I=null,U=null,me=null,Ke=null;if(_f=!j,_f&&(j="<!-->"),typeof j!="string"&&!Xy(j))if(typeof j.toString=="function"){if(j=j.toString(),typeof j!="string")throw wl("dirty is not a string, aborting")}else throw wl("toString is not a function");if(!t.isSupported)return j;if(Fl||Ff(E),t.removed=[],typeof j=="string"&&(Ts=!1),Ts){if(j.nodeName){let uo=De(j.nodeName);if(!J[uo]||vr[uo])throw wl("root node is forbidden and cannot be sanitized in-place")}}else if(j instanceof a)I=qy("<!---->"),U=I.ownerDocument.importNode(j,!0),U.nodeType===1&&U.nodeName==="BODY"||U.nodeName==="HTML"?I=U:I.appendChild(U);else{if(!Ot&&!Qt&&!Zt&&j.indexOf("<")===-1)return S&&Ul?S.createHTML(j):j;if(I=qy(j),!I)return Ot?null:Ul?x:""}I&&ut&&lo(I.firstChild);let We=Gy(Ts?j:I);for(;me=We.nextNode();)Yy(me)||(me.content instanceof i&&Uk(me.content),Jy(me));if(Ts)return j;if(Ot){if(Hl)for(Ke=R.call(I.ownerDocument);I.firstChild;)Ke.appendChild(I.firstChild);else Ke=I;return(we.shadowroot||we.shadowrootmode)&&(Ke=_.call(r,Ke,!0)),Ke}let ct=Zt?I.outerHTML:I.innerHTML;return Zt&&J["!doctype"]&&I.ownerDocument&&I.ownerDocument.doctype&&I.ownerDocument.doctype.name&&At(ET,I.ownerDocument.doctype.name)&&(ct="<!DOCTYPE "+I.ownerDocument.doctype.name+`>
24
+ `+ct),Qt&&vf([G,Z,se],uo=>{ct=Sl(ct,uo," ")}),S&&Ul?S.createHTML(ct):ct},t.setConfig=function(){let j=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ff(j),Fl=!0},t.clearConfig=function(){oi=null,Fl=!1},t.isValidAttribute=function(j,E,I){oi||Ff({});let U=De(j),me=De(E);return Qy(U,me,I)},t.addHook=function(j,E){typeof E=="function"&&(D[j]=D[j]||[],vl(D[j],E))},t.removeHook=function(j){if(D[j])return pT(D[j])},t.removeHooks=function(j){D[j]&&(D[j]=[])},t.removeAllHooks=function(){D={}},t}var CT=bT();var oo=w(H());var kM={"":["<em>","</em>"],_:["<strong>","</strong>"],"*":["<strong>","</strong>"],"~":["<s>","</s>"],"\n":["<br />"]," ":["<br />"],"-":["<hr />"]};function TT(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function xl(e){return(e+"").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function El(e,t){var n,r,o,i,s,a=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,l=[],u="",c=t||{},m=0;function d(v){var y=kM[v[1]||""],g=l[l.length-1]==v;return y?y[1]?(g?l.pop():l.push(v),y[0|g]):y[0]:v}function f(){for(var v="";l.length;)v+=d(l[l.length-1]);return v}for(e=e.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(v,y,g){return c[y.toLowerCase()]=g,""}).replace(/^\n+|\n+$/g,"");o=a.exec(e);)r=e.substring(m,o.index),m=a.lastIndex,n=o[0],r.match(/[^\\](\\\\)*\\$/)||((s=o[3]||o[4])?n='<pre class="code '+(o[4]?"poetry":o[2].toLowerCase())+'"><code'+(o[2]?' class="language-'+o[2].toLowerCase()+'"':"")+">"+TT(xl(s).replace(/^\n+|\n+$/g,""))+"</code></pre>":(s=o[6])?(s.match(/\./)&&(o[5]=o[5].replace(/^\d+/gm,"")),i=El(TT(o[5].replace(/^\s*[>*+.-]/gm,""))),s==">"?s="blockquote":(s=s.match(/\./)?"ol":"ul",i=i.replace(/^(.*)(\n|$)/gm,"<li>$1</li>")),n="<"+s+">"+i+"</"+s+">"):o[8]?n='<img src="'+xl(o[8])+'" alt="'+xl(o[7])+'">':o[10]?(u=u.replace("<a>",'<a href="'+xl(o[11]||c[r.toLowerCase()])+'">'),n=f()+"</a>"):o[9]?n="<a>":o[12]||o[14]?n="<"+(s="h"+(o[14]?o[14].length:o[13]>"="?1:2))+">"+El(o[12]||o[15],c)+"</"+s+">":o[16]?n="<code>"+xl(o[16])+"</code>":(o[17]||o[1])&&(n=d(o[17]||"--"))),u+=r,u+=n;return(u+e.substring(m)+f()).replace(/^\n+|\n+$/g,"")}var kT={root:"dd-L7b3z",popover:"dd-OQOTB",options:"dd-Y12RE",arrow:"dd-cv33T",copyIcon:"dd-6xOsH",option:"dd-9oFX4",divider:"dd-aiZf8",fadeup:"dd-Jq9pd"};var In=w(b());function PM(e){return`<button type="button" class=${e}><svg version="1.1" x="0px" y="0px" viewBox="0 0 115.77 122.88" width="10px" height="10px" fill="black"><g><path d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"/></g></svg></button>`}function Ey(e){var n;let t=e.cloneNode(!0);return t.querySelectorAll("div,button").forEach(r=>r.remove()),(n=t.textContent)!=null?n:""}function RM(e){return e.replace(/\r\n/g,`
25
+ `)}var AM=({content:e,useLabel:t,copyLabel:n,onCopy:r,onUse:o})=>{let i=A("Markdown",kT),s=(0,oo.useRef)(null),[a,l]=(0,oo.useState)(null),u=(0,oo.useMemo)(()=>{let y=El(RM(e));return CT.sanitize(y).replace(/<\/code>/g,`${PM(i.copyIcon)}</code>`)},[e]),c=y=>{var h;let g=y.target,p=!!((h=s.current)!=null&&h.querySelector("code"));a||p&&g.tagName!=="CODE"||!p&&g!==s.current||(g.addEventListener("mouseleave",()=>l(null),{once:!0}),l(g))},m=()=>{if(!a)return;l(null);let y=a.querySelector("button");y&&(ls(y,i.fadeup),r(Ey(a)))},d=y=>{y.target.tagName.toLowerCase()==="button"&&(ls(y.target,i.fadeup),r(Ey(y.target.parentElement)))},f=()=>{a&&(l(null),o(Ey(a)))},v=y=>{if(y===null)return;let g=y.getBoundingClientRect();g.left<0?y.style.transform=`translateX(${-g.left+2}px)`:g.right>window.innerWidth&&(y.style.transform=`translateX(${window.innerWidth-g.right-2}px)`)};return(0,In.jsxs)(oo.Fragment,{children:[a&&(0,In.jsxs)(vs,{triggerRef:{current:a},className:i.popover,parentNode:a,children:[(0,In.jsxs)("div",{className:i.options,ref:v,children:[(0,In.jsx)("button",{type:"button",className:i.option,onClick:m,children:n}),(0,In.jsx)("div",{className:i.divider}),(0,In.jsx)("button",{type:"button",className:i.option,onClick:f,children:t})]}),(0,In.jsx)("div",{className:i.arrow})]}),(0,In.jsx)("div",{ref:s,className:i.root,dangerouslySetInnerHTML:{__html:u},onMouseOver:c,onClick:d})]})},PT=AM;var by={};$e(by,{enUS:()=>LM,nlNL:()=>IM});var LM={useCue:[{type:0,value:"Add to message"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},IM={useCue:[{type:0,value:"Voeg toe aan bericht"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var RT={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l"};var gn=w(b()),NM=({cue:e,onRemove:t,onCopy:n,onUse:r})=>{let o=A("WidgetCue",RT),i=q(by),s=us(),a=c=>{n&&n(c,e)},l=c=>{r&&r(c,e)},u=c=>{c.preventDefault(),c.stopPropagation(),t(e)};return(0,AT.useEffect)(()=>{s("Assistant response displayed",{name:e.rule.name,description:e.rule.description,group:e.rule.label,cueText:e.text})},[]),(0,gn.jsxs)(oe,{"data-testid":"cue",children:[(0,gn.jsx)(ye,{children:(0,gn.jsxs)(ye.Content,{children:[e.title&&(0,gn.jsx)(ye.Title,{className:o.title,"data-testid":"widget-cue-title",children:e.title}),(0,gn.jsx)(PT,{content:e.text,useLabel:i("useCue"),copyLabel:i("copyCue"),onCopy:a,onUse:l})]})}),(0,gn.jsxs)(oe.IconButtonContainer,{children:[(0,gn.jsx)(ds,{eventName:"Assistant response feedback",eventData:{name:e.rule.name,group:e.rule.label,description:e.rule.description,cueText:e.text},feedbackText:e.text,feedbackType:"assistant"}),(0,gn.jsx)(oe.IconButton,{title:i("removeCue"),onClick:u,icon:(0,gn.jsx)(dT,{})})]})]})},LT=NM;var bl=w(b()),OM=({cues:e})=>{let t=X(),n=Wt(),r=us(),o=a=>{t($C({id:a.rule.id})),r("Assistant response closed",{name:a.rule.name,group:a.rule.label,description:a.rule.description,cueText:a.text})},i=(a,l)=>{Yn(a),r("Assistant response copied",{name:l.rule.name,group:l.rule.label,description:l.rule.description,copiedText:a})},s=(a,l)=>{n.send(Gr,{text:a,suggestion:{source:"cue",sourceText:a}}),r("Assistant response used",{name:l.rule.name,group:l.rule.label,description:l.rule.description,usedText:a})};return(0,bl.jsx)(bl.Fragment,{children:e.map(a=>(0,bl.jsx)(LT,{cue:a,onRemove:o,onCopy:i,onUse:s},a.rule.id))})},IT=OM;var Ef=w(H());var NT={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var hn=w(b());function MM(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var OT=({data:e,schema:t})=>{let n=A("WidgetCustomData",NT),r=o=>{Yn(o)};return(0,Ef.useEffect)(()=>{z.info("Custom data",e,t)},[e]),(0,hn.jsx)("dl",{className:n.root,children:t.map(o=>{let i=MM(e,o.path);return(0,hn.jsxs)(Ef.Fragment,{children:[(0,hn.jsx)("dt",{className:n.label,children:o.label}),(0,hn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&i?(0,hn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!i?(0,hn.jsx)("span",{className:n.isFalse,children:o.falseValue}):i?(0,hn.jsxs)("button",{type:"button",onClick:()=>r(i),className:n.copyButton,children:[(0,hn.jsx)("span",{children:i}),(0,hn.jsx)(hl,{})]}):"-"})]},o.label)})})};var _T=w(H());var _M=/(https?:\/\/[^\s]+)/,MT=e=>e.split(" ").find(t=>_M.test(t));var Xt=w(b()),DM=({suggestion:e,lines:t,onUse:n})=>{var c;let r=e.text||e.url||e.message,o=MT(r),i=q(Vo),s=V("showImages"),a=V("fallbackImage"),l=m=>{m.preventDefault(),m.stopPropagation(),n(r)},u=(0,_T.useCallback)(m=>{window.open(o,"_blank"),m.stopPropagation(),m.preventDefault()},[o]);return(0,Xt.jsxs)(oe,{onClick:l,"data-testid":"edit-suggestion",children:[(0,Xt.jsxs)(ye,{children:[s&&e.image&&(0,Xt.jsx)(ye.Image,{src:df(e,"small",a||void 0),title:e.title}),(0,Xt.jsxs)(ye.Content,{children:[e.title&&(0,Xt.jsx)(ye.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((c=e.searchKeywords)==null?void 0:c.length)>0&&(0,Xt.jsx)(oe.Labels,{labels:e.searchKeywords}),(0,Xt.jsx)(ye.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,Xt.jsxs)(oe.Actions,{children:[o&&(0,Xt.jsx)(oe.ActionButton,{onClick:u,label:i("visitUrl")}),(0,Xt.jsx)(oe.ActionButton,{primary:!0,onClick:l,label:i("useSuggestion")})]})]})},DT=DM;var Cl=w(b()),FM=({lines:e,suggestions:t})=>{let n=Wt(),r=(o,i)=>{n.send(Gr,{text:o,suggestion:O(P({},i),{source:i.source,sourceText:i.text})})};return(0,Cl.jsx)(Cl.Fragment,{children:t.map(o=>(0,Cl.jsx)(DT,{suggestion:o,lines:e,onUse:i=>r(i,o)},o.text||o.url||o.message))})},FT=FM;var Tl={};$e(Tl,{enUS:()=>HM,nlNL:()=>UM});var HM={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"My "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},UM={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],titleCues:[{type:0,value:"Assistant updates"}],actions:[{type:0,value:"Shortcuts"}],linkStudioLogin:[{type:0,value:"Mijn "},{type:1,value:"productName"}],linkSummary:[{type:0,value:"Gesprek samenvatten"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var kl={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",sectionList:"dd-bF9pF",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",link:"dd-DRo0x"};var $=w(b()),bf=(e,t)=>{let n=M(rt);(0,Pl.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},zM=({onLogIn:e})=>{let t=A("Widget",kl),n=V("isEmbedded"),r=V("adminUrl");return(0,$.jsx)("div",{className:t.loginText,children:(0,$.jsx)("div",{children:(0,$.jsx)(Qd,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},HT=({text:e})=>{let t=A("Widget",kl);return(0,$.jsx)("div",{className:t.stateText,children:(0,$.jsx)("div",{children:(0,$.jsx)("p",{children:e})})},"notification")},BM=()=>{let e=q(Tl),t=X(),n=A("Widget",kl),r=V("showSearch"),o=V("showSummaryCommand"),i=V("showKnowledgeSearch"),s=M(cs("/admin/")),a=Wt(),l=V("productName"),u=r||o||i||s;return bf(()=>(t(iy()),()=>{t(BC())}),[t]),u?(0,$.jsx)(vn,{title:e("actions"),type:"shortcuts",children:(0,$.jsxs)("div",{className:n.shortcutList,children:[r&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-search","aria-label":e("linkSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0}),children:[(0,$.jsx)(ss,{}),e("linkSearch")]}),o&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-summary","aria-label":e("linkSummary"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[(0,$.jsx)(cT,{}),e("linkSummary")]}),i&&(0,$.jsxs)("button",{type:"button",className:n.shortcut,"data-testid":"shortcut-knowledge-assist","aria-label":e("linkKnowledgeSearch"),onClick:()=>a.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeAssist"}),children:[(0,$.jsx)(uT,{}),e("linkKnowledgeSearch")]}),s&&(0,$.jsxs)("a",{className:n.shortcut,target:"_blank",href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:l}),rel:"noreferrer",children:[(0,$.jsx)(lT,{}),e("linkStudioLogin",{productName:l})]})]})}):null},jM=()=>{let e=X(),t=V("showCustomMessages"),n=M(NC),r=M(Zi);return bf(()=>(e(gl(r)),e(FC(r)),()=>{e(HC(r))}),[e,t,r]),!t||n.length===0?null:(0,$.jsx)(vn,{type:"custom-messages","data-testid":"custom-messages",children:(0,$.jsx)(mt,{withDivider:!0,children:n.map(o=>(0,$.jsx)(iT,{suggestion:o},o.text))})})},VM=()=>{let e=q(Tl),t=X(),n=V("showAutoflows"),r=M(PC),o=M(Zi);return bf(()=>(t(cr(o)),t(RC(o)),()=>{t(AC(o))}),[t,n,o]),!n||r.length===0?null:(0,$.jsx)(vn,{type:"autoflows",title:e("titleAutoflows"),"data-testid":"autoflows",children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(rT,{})})})},KM=()=>{let e=X(),t=M(zd),n=M(fb),r=M(KC),o=M(F1),i=M(Hd),s=M(Bd),a=M(or),l=M(qr);return(0,Pl.useEffect)(()=>{!!o&&!n&&z.warn("Custom data provided, but no schema.")},[o,n]),bf(()=>{t.forEach(({type:u})=>{u==="entities"?e(cn()):nu.includes(u)||e(fn(u))})},[e,l,a]),(0,$.jsx)(Pl.Fragment,{children:t.map(({type:u,title:c,amount:m,lines:d,schema:f})=>{var v,y;switch(u){case"entities":return i&&i.length>0&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(aT,{entities:i})},u);case"cues":return r&&r.length>0&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(IT,{cues:r})})},u);case"custom-data":return o&&f&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(OT,{data:o,schema:f})})},u);default:return((y=(v=s[u])==null?void 0:v.suggestions)==null?void 0:y.length)>0&&(0,$.jsx)(vn,{type:u,title:c,"data-testid":`type-${u}`,children:(0,$.jsx)(mt,{withDivider:!0,children:(0,$.jsx)(FT,{lines:d,contentType:u,suggestions:s[u].suggestions.slice(0,m)||[]})})},u)}})})},WM=({onLogIn:e})=>{let t=q(Tl),n=A("Widget",kl),r=M(Ji),o=M(rt),i=M(Zi),s=M(or);return r===!1?(0,$.jsx)(HT,{text:t("notSupported")}):o===!1?(0,$.jsx)(zM,{onLogIn:e}):!s||!i||o===null?(0,$.jsx)(HT,{text:t("waiting")}):(0,$.jsx)("div",{className:(0,UT.default)(n.root),"data-testid":"widget",children:(0,$.jsxs)(Jl,{className:n.sectionList,children:[(0,$.jsx)(BM,{}),(0,$.jsx)(jM,{}),(0,$.jsx)(VM,{}),(0,$.jsx)(KM,{})]})})},zT=WM;function Ss(e){let t=new Range;return t.selectNodeContents(e),t}function BT(e,t,n){try{return io(e,t,n),!0}catch(r){return!1}}function Cf(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function Tf(e){return"tagName"in e&&e.tagName==="BR"}var Rl=/[\u200B-\u200D\uFEFF]/g;function io(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,i=!1;function s(l,u){let c=-1,m=/[\u200B-\u200D\uFEFF]/;if(!m.test(l))return u;for(let d=0;d<=l.length;d++)if(m.test(l[d])||c++,c===u)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,c=u.replace(Rl,""),m=o+c.length,d=t>=o&&t<=m,f=n>=o&&n<=m;if(d){let v=s(u,t-o);v===0&&!f?r.setStartBefore(l):r.setStart(l,v)}f&&(r.setEnd(l,s(u,n-o)),i=!0),o=m;break}case Node.ELEMENT_NODE:{if(Tf(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),i=!0;return}for(let c=0;c<l.childNodes.length&&(a(l.childNodes[c]),!i);c++);let u=l.lastChild;Cf(l)&&u&&!Cf(u)&&!Tf(u)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Al(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i,collapsed:s}=t,a,l,u=0;function c(m){let d=m===n,f=m===o;switch(m.nodeType){case Node.TEXT_NODE:{let v=m.textContent;d&&(a=u+v.substring(0,r).replace(Rl,"").length),f&&(l=u+v.substring(0,i).replace(Rl,"").length),u+=v.replace(Rl,"").length;break}case Node.ELEMENT_NODE:{let v=m.nextSibling===null;Tf(m)&&!v&&u++;for(let y=0;y<m.childNodes.length;y++){let g=d&&y===r,p=f&&y===i;if(g&&(a=u),p&&(l=u),l!==void 0||((!g||!s)&&c(m.childNodes[y]),f&&y===i-1&&(l=u),l!==void 0))break}!f&&Cf(m)&&!v&&u++,f&&(l=u);break}default:break}}if(c(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Ll(e,t){if(!e.contains(t.startContainer)||!e.contains(t.endContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:r,endContainer:o,endOffset:i}=t,s=-1,a="";function l(u){let c=u===n,m=u===o;switch(c&&s++,u.nodeType){case Node.TEXT_NODE:{if(s!==0)return;let d=c?r:0,f=m?i:void 0,v=u.textContent.replace(Rl,"");d===0&&f===void 0?a+=v:a+=v.substring(d,f);break}case Node.ELEMENT_NODE:{let d=u.nextSibling===null;s===0&&Tf(u)&&!d&&(a+=`
26
26
  `);for(let f=c?r:0;f<(m?Math.min(i,u.childNodes.length):u.childNodes.length)&&(l(u.childNodes[f]),s!==1);f++);!m&&s===0&&Cf(u)&&!d&&(a+=`
27
- `);break}default:break}m&&s++}return l(e),a}var jT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(jT||{}),fr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.getCaretPosition();this.isActive&&(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText&&(this.cachedText=t,this.cachedHTML=n,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,this.emit("selection",r)),$r(o,this.cachedCaretPosition)||(this.cachedCaretPosition=o,this.emit("caretposition",o)))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(jT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),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.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function VT(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Yo=class extends fr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ll(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!VT(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!VT(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Al(this.element,n);let r=this.lastKnownSelection;if(r&&BT(this.element,r.start,r.end))return r;let o=Ss(this.element);return o.collapse(!1),Al(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ll(this.element,io(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(()=>{setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var Qo=class extends fr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return null}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function KT(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function $M(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Cy=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Ty=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=KT(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},ky=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),U.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Ty(t,this.deepdeskUrl,{debug:!0}):new Cy(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=$M(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(U.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;U.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(O(P({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},WT=ky;var ws=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Py=e=>new Promise(t=>{setTimeout(t,e)});var xs=class extends ws{constructor(){super(...arguments);this.name="ClientError"}},Ay=class extends ws{constructor(){super(...arguments);this.name="ServerError"}},Ry=new Map;function qM(e){return k(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(U.warn("Unexpected response body:",n.slice(0,20)),U.warn("body (1):",n.slice(0,249)),U.warn("body (2):",n.slice(250,499)),U.warn("body (3):",n.slice(500,749)),U.warn("body (4):",n.slice(750,1e3)),JSON.parse(n))})}var so=class so{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:u=!1,abortLatest:c=!1,attempts:m=1,retryDelay:d=500,refreshTokenOn401:f=!0,retryOnError:v=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:g="v1"}=C,p=te(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(Ry.has(s)){r(Ry.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=O(P({credentials:"include"},p),{headers:P({"Content-Type":"application/json"},p.headers)});!l&&this.csrfToken&&(h.headers=O(P({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(h.headers=O(P({},h.headers),{"X-Deepdesk-API-Version":g}));let S=m,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let T=()=>k(this,null,function*(){return S--,a(s,h).then(R=>k(this,null,function*(){return y(R)&&!i.isAborted&&S>0?(yield Py(d),T()):R.status===401&&f===!0&&x===!1?(x=!0,yield this.refreshToken(),T()):R})).catch(R=>k(this,null,function*(){if(v(R)&&!i.isAborted&&S>0)return yield Py(d),T();throw R}))});T().then(R=>k(this,null,function*(){let N=yield qM(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new Ay("Server Error",N));return}else if(R.status===401){o(new xs("Unauthorized",N));return}else if(R.status===403){o(new xs("Forbidden",N));return}else if(R.status===404){o(new xs("Not Found",N));return}else if(R.status>=400){o(new xs("Bad Request",N));return}u&&Ry.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return k(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)return!1;let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/",{version:null});return!!n})}refreshToken(){return so.refreshingToken||(so.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{so.refreshingToken=null},1e3*60)})),so.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,P({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,P({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,P({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,P({method:"DELETE"},n))}};so.refreshingToken=null;var yn=so;var $T;(t=>{let e;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})($T||($T={}));function kf(e){return O(P({},re(e)),{tags:e.tags})}var Zo=class Zo{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new yn(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>k(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return k(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(Zo.exchangeTokenPromise||(Zo.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Zo.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return k(this,null,function*(){yield this.preflight(),U.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",O(P({},Ne(t)),{tags:t.tags}),{version:"v2"});return kf(n)})}getProfile(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{version:null,useCache:!0});return re(n)})}getKnowledgeAssistant(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null,useCache:!0});return re(n)})}getContentTypes(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return re(t)})}getAccount(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{version:null,useCache:!0});return re(t)})}getPlatformConfig(){return k(this,null,function*(){let{config:t}=yield this.client.get("/platform/config/",{version:null,useCache:!0});return re(t)})}checkUserExists(t){return k(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n})}getConversationBySessionId(r){return k(this,arguments,function*(t,n={}){yield this.preflight(),U.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return U.info(`Successfully retrieved conversation ${s.id} for session ${t}`),kf(s)})}isConversationSupported(r){return k(this,arguments,function*(t,n={}){U.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return k(this,null,function*(){let r=Ne(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return kf(o)})}postMessages(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>O(P({},Ne(o)),{tags:o.tags})),{version:"v2"})).map(o=>kf(o))})}sendEvent(t,n){return k(this,null,function*(){let s=n,{data:r}=s,o=te(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>O(P({},a),{[l]:u}),{});return this.client.post("/api/events",Ne(O(P(P({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return k(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>O(P({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ne(P(P({},n),r))})})}getEntities(t){return k(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities})}getSummary(r){return k(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model});return re(o)})}getTemporaryExchangeToken(){return k(this,null,function*(){return(yield this.client.get("/auth/exchange-token",{version:null})).jwt})}exchangeTokenForAccessCookie(t){return k(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw U.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return k(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ne(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return k(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Ne(n),{abortLatest:!0})).map(s=>O(P({},re(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return k(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Ne(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return re(n).map(r=>O(P({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return k(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ne(t),{abortLatest:!0});return re(n)})}search(t){return k(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ne(t),{version:"v2"});return re(n)})}knowledgeAssist(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ne({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return re(l)})}requestLoginByEmail(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return re(n)})}requestPasswordlessToken(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/",{version:null});return re(t.token)})}getCsrfToken(){return k(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/",{version:null});return t})}verifyLoginToken(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return re(n)})}evaluateRule(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?re(u.cues):[]})}getRules(){return k(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{version:null,useCache:!0});return re(n)})}translateMessages(t){return k(this,null,function*(){let n=yield this.client.post("/api/translate",Ne(t),{version:"v2"});return re(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(qv);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&U.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};Zo.exchangeTokenPromise=null;var pr=Zo;var Il=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=P({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(Jg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,re(o))}catch(o){U.warn(`Invalid JSON for ${t}: ${r}`)}})}connect(){clearTimeout(this.timeoutTimer);let t=new EventSource(this.url,{withCredentials:!0});this.eventSource=t;let n=!1;t.onopen=()=>{n=!0},t.onerror=()=>{n&&t.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{t.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(r=>{this.proxyEvent(r)})}disconnect(){var t;clearTimeout(this.timeoutTimer),this.eventListeners={},(t=this.eventSource)==null||t.close()}emit(t,n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>r(n))}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),this.proxyEvent(t),()=>{this.off(t,n)}}off(t,n){let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}};var qT;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(qT||(qT={}));var Nl=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=U;this.client=new yn(t,n)}getCustomMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return re(n.suggestions)})}sendCustomMessage(t,n){return k(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Ne(n));return re(r)})}answerCustomMessage(t,n){return k(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Ne(n))})}getAutoflows(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return re(n.autoflows)})}startAutoflowSession(t){return k(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Ne(t));return re(n)})}stopAutoflowSession(t){return k(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new Il(`${this.apiUrl}/sessions/${t}/events`),this.streams[t].connect()),this.streams[t]}closeStream(t){this.streams[t]||(this.streams[t].disconnect(),delete this.streams[t])}};var GT={startTime:null,stopTime:null},XT=Q({name:"handlingTime",initialState:GT,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(fe,()=>GT)}}),{handlingTimeStart:YT,handlingTimeStop:Pf,handlingTimeReset:QT}=XT.actions,ZT=XT.reducer;var JT=(e={})=>{let t=P({onAuthError:Qi(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Rf={list:{keywordMatches:[]},fetchState:"idle"};var Jo=K("styleSuggestions/getAll",(n,r)=>k(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Rf.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),GM=Q({name:"styleSuggestions",initialState:Rf,reducers:{},extraReducers:e=>{e.addCase(Jo.pending,t=>{t.fetchState="loading"}).addCase(Jo.rejected,t=>{t.fetchState="error"}).addCase(Jo.fulfilled,(t,n)=>{t.fetchState="done",$r(t.list,n.payload)||(t.list=n.payload)}).addCase(Io,t=>{t.list=Rf.list}).addCase(fe,()=>Rf)}}),ek=GM.reducer;var tk=(e={})=>{let t,n=!0,r=P({getStyleSuggestions:Jo,debounce:500},e);return o=>i=>s=>{var f;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((f=u.conversation.current)==null?void 0:f.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function XM(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var nk=(e={})=>{let t=P({getTextSuggestions:fn,getAutocompleteSuggestions:ul,debounce:200,check:Rn},e),n;return r=>o=>i=>{var y;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,m=(y=l.conversation.current)==null?void 0:y.id,d=i.type===jd.toString();if(!m||!u&&!c)return a;let{input:f}=l;return XM(f,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=es(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var rk=Jo.fulfilled.toString();function YM(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var ok=e=>t=>n=>r=>{var u;if(r.type!==rk){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=YM(o,s);r.type===rk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var QM=Ec({answer:ub,auth:p1,autoflows:LC,conversation:b1,contentTypes:SE,customMessages:UC,passwordlessToken:jC,entities:KE,knowledgeAssistant:sb,handlingTime:ZT,info:B1,input:_1,settings:s1,profile:pb,search:G1,summary:QE,styleSuggestions:ek,ui:jb,rules:qC,textSuggestions:xb});function ik(e){return fx({reducer:QM,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),JT(),nk({debounce:200}),tk({debounce:500}),ok(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var ZM=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},JM=e=>t=>n=>r=>{var a,l,u,c,m,d;let o=t.getState(),i=qg("inlineSuggestions")(o);switch(r.type){case Qi.toString():{!r.payload&&e.emit("logout",void 0);break}case cn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case ot.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Io.toString():e.logSendMessage(r.payload);break;case Go.fulfilled.toString():r.isBroadcasted||e.broadcast(nh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;default:break}let s=n(r);switch(r.type){case Io.toString():e.handleAfterSendMessage(r.payload);break;case dl.toString():e.onUpdateShowTabHint(r.payload);break;case Pf.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case rd.toString():{let{start:f,end:v}=o.input.selection;e.emit("replace",O(P({},r.payload),{replace:r.payload.replace==="selection"?{start:f,end:v}:{start:0,end:v}}));break}case rn.toString():{let{start:f,end:v}=o.input.selection;e.emit("select-suggestion",O(P({type:ZM(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:f,end:v}:{start:0,end:v}})),i&&t.dispatch(Xn([]));break}case od.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(m=o.conversation.current)==null?void 0:m.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Xn.toString():{i&&r.payload.length>0&&t.dispatch(id(0));break}case tr.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload.summary,model:t.getState().summary.model}});break}default:break}return s},sk=JM;function Ly(e){return e.toISOString().replace("T"," ").replace("Z","")}function ak(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return U.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(U.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:n,clientVersion:t.version,agentId:(s=e.info.agentInfo)==null?void 0:s.agentId,agentName:(a=e.info.agentInfo)==null?void 0:a.agentName,agentEmail:(l=e.info.agentInfo)==null?void 0:l.agentEmail,timeStart:Ly(r),timeStop:Ly(o)}}function lk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return U.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:m,pastes:d,cuts:f,deletions:v,textSuggestions:y,offeredTextSuggestions:g}}=t[e],p=o.length,S=y.reduce((Z,{text:se,searchTerm:mr})=>Z+se.length-(mr?mr.length:0),0),x=c!=null?c:Date.now(),T=(Date.now()-x)/1e3+(m||0),C=i/T,R=y.reduce((Z,{searchTerm:se})=>Z+(se?se.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:f,deletions:v,lenTextTyped:i+R,lenTextTotal:p,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:T,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:g.filter(Z=>Z.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(D=t.info.agentInfo)==null?void 0:D.agentName,agentEmail:(G=t.info.agentInfo)==null?void 0:G.agentEmail}}function Iy(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Iy(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Iy(o,t):null}function uk(e,t){return Iy(e,t)}function ck(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function e2(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Af(e){return e2(e)&&(to(e)||Jd(e))}var fk,Nn=new Map,t2=["bottom","height","left","right","top","width"],dk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:t2.some(n=>e[n]!==t[n]);function pk(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...pk(t)]:[]}function mk(e,t){return!e||!t?null:O(P({},e),{top:e.top+t.top,left:e.left+t.left})}var Lf=!1,gk=()=>{Lf=!0;let e=[];if(Nn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Nn.delete(n);return}let r=n.getBoundingClientRect();dk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(mk,t.rect):t.rect;dk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Nn.size===0){Lf=!1;return}fk=window.requestAnimationFrame(gk)};function Ny(e,t){let n=pk(e),r=[],o=n.map((i,s)=>Ny(i,a=>{r[s]=a;let l=Nn.get(e);if(!l)return;let u=r.reduce(mk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Nn.has(e)){let s=Nn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Nn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Lf&&gk()},unobserve(){o.forEach(s=>s.unobserve());let i=Nn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Nn.delete(e),Nn.size||(cancelAnimationFrame(fk),Lf=!1)}}}}var hk,On=new Map,yk=()=>{On.forEach((e,t)=>{if(!t.isConnected){On.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),On.size!==0&&(hk=window.requestAnimationFrame(yk))};function vk(e,t){return{observe(){let n=On.size===0;On.has(e)?On.get(e).callbacks.push(t):On.set(e,{visible:void 0,callbacks:[t]}),n&&yk()},unobserve(){let n=On.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||On.delete(e),On.size||cancelAnimationFrame(hk)}}}}var Oy=["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 My(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Es(e){return parseFloat(e)}function If(e){return Math.round(e*1e6)}function Sk(e){return e/1e6}function _y(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Es(e.width),i=Es(e.borderLeftWidth),s=Es(e.borderRightWidth),a=Es(e.paddingRight),l=Sk(If(o)-If(i)-If(s)),u=Sk(If(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Ol(e,t={}){var c,m;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",Wo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};My(r,n,Oy),_y(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=vk(e,()=>{My(r,n,Oy),_y(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Ny(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(My(r,n,Oy),_y(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let f=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),y=Es(v.borderTopWidth),g=Es(v.borderBottomWidth),p=f.top+y-d.top,h=d.top+d.height+-(f.top+f.height-g);n.style.clipPath=`inset(${p}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(m=e.parentElement)==null||m.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var wk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){U.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function n2(e){return e.offsetParent!==null}function xk(e){if(!n2(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Nf(e,t,n=100){let r=xk(e);t({isVisible:r});let o=setInterval(()=>{let i=xk(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var _e=w(b());var Ek=wk("showTabHint",!0),bs=class bs{constructor({deepdeskUrl:t,brokerUrl:n,version:r=bs.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new pr(u,{token:i,fetch:s}),this.version=r,this.instanceId=bs.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[sk({broadcast:(m,d,f)=>{this.broadcastEvents.send(m,d,f)},emit:(m,d)=>this.emit(m,d),handleAfterSendMessage:m=>this.handleAfterSendMessage(m),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:m=>this.logSendMessage(m),onUpdateShowTabHint:m=>Ek.update(m),sendEvent:(m,d)=>this.deepdeskApi.sendEvent(m,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Nl(n)}),this.store=ik(c),this.broadcastEvents=new WT({debug:!0,deepdeskUrl:u,eventMap:X1(this.store),createCustomChannel:l}),this.store.dispatch(dl(Ek.value())),this.store.dispatch(Qc({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t: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?(U.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(U.warn("Profile has not been loaded (yet)"),!0):(U.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Qi(null)),this.store.dispatch(qn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();rt(r)&&a1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return k(this,null,function*(){return(yield this.store.dispatch(qn())).payload})}setPlatformAgentId(t){return k(this,null,function*(){try{if((yield this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;yield this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){U.warn("Failed to attach user:",n)}})}isConversationSupported(t,n){return k(this,null,function*(){return(yield this.store.dispatch(Yg({sessionId:t,options:n}))).payload})}createConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(Jc(t))).payload})}getConversationBySessionId(t,n){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(ed({sessionId:t,options:n}))).payload})}upsertConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(Qg(t))).payload})}postMessages(t){return k(this,null,function*(){return(yield this.store.dispatch(nd(t))).payload})}updateConversation(t){return k(this,null,function*(){return(yield this.store.dispatch(td(t))).payload})}resetConversation(){this.store.dispatch(fe()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}getSummary(){return k(this,null,function*(){let t=yield this.store.dispatch(tr());if(t.error)throw new Error(t.error.message);return t.payload.summary})}configure(t){this.store.dispatch(Qc(t))}setVisitorInfo(t){this.store.dispatch(U1(t))}setCustomData(t){this.store.dispatch(z1(t))}setAgentInfo(t){return k(this,null,function*(){yield this.store.dispatch(za(t))})}setAgentSettings(t){return k(this,null,function*(){yield this.store.dispatch(eh(t))})}getAgentSettings(){return k(this,null,function*(){return(yield this.store.dispatch(th())).payload})}refresh(){return k(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(sd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(jd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(rn(t))}evaluateRule(o){return k(this,arguments,function*(t,n={},r=VC){return(yield this.store.dispatch(Go({label:t,params:n,options:r}))).payload.cues})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!Rn(this.state)||(this.store.dispatch(R1(Zg(t))),t.key!=="Tab"&&!l))return;let m=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(I1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(N1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():m();break;case"ArrowDown":{u==="below"?m():d();break}case"Escape":{n||(this.store.dispatch(id(-1)),this.store.dispatch(Jr({collapse:!0})),this.store.dispatch(zb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let f=ts(this.state);if(!f)return;this.store.dispatch(dl(!1)),this.store.dispatch(rn({text:f.text,suggestion:f,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let f=ts(this.state);if(!f)return;this.store.dispatch(rn({text:f.text,suggestion:f,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let f=ts(this.state);if(!f)return;this.store.dispatch(rn({text:f.text,suggestion:f,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(Jr({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Xn([]))}handlingTimeStart(){this.state.handlingTime.startTime||(U.info("Start handling time"),this.store.dispatch(YT()))}handlingTimeStop(){this.state.handlingTime.startTime&&(U.info("Stop handling time"),this.store.dispatch(Pf()))}logSendMessage(t){let n=lk("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=ak(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(QT()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Io((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(M1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){U.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),U.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=Ol(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Yt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i.ownerDocument.defaultView;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Ol(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,Yt.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Wo(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,Yt.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),U.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(U.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(O1(r.metrics))):U.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Af(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:m,detectSubmit:d,insertLink:f,inputMediator:v,closestScrollSelector:y,appendOverlayTo:g,inlineSuggestions:p,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:f,isEmbedded:m,inlineSuggestions:p,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),Wo(t),this.inputMediator=v||(to(t)?new Qo(t):new Yo(t)),this.inputMediator.on("change",({plainText:T,rawHTML:C})=>{this.store.dispatch(sd({text:T,html:C}))}),this.inputMediator.on("keyup",T=>{this.store.dispatch(A1(Zg(T)))}),this.inputMediator.on("keydown",T=>{this.handleKeyDown(T)}),this.inputMediator.on("paste",({pastedText:T,selectionText:C})=>{this.store.dispatch(L1({text:T,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:T})=>{this.store.dispatch(P1(T))});let S;this.inputMediator.on("selection",T=>{clearTimeout(S),T===null?S=setTimeout(()=>{T!==null&&this.store.dispatch(ad(T))},500):this.store.dispatch(ad(T))}),this.inputMediator.on("disabled",()=>{var T;(T=this.inputMediator)==null||T.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(qd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(qd(!0))});let x=y&&uk(t,y)||void 0;if(p){let{customStyles:T,appendOverlayTo:C}=n;if(to(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:T,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Gb,{})})}),R),this.inputMediator.on("caretposition",_=>{this.store.dispatch(Xn([])),_?(R.style.display="block",R.style.top=`${_.top}px`,R.style.left=`${_.left}px`):R.style.display="none"});let N=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:C},T==null?void 0:T.floatingMenuRootNode);(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:T,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Fb,{onLogIn:()=>this.loginViaPopup().catch(_=>U.warn(_.message))})})}),N)}else{let T=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:g,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(CC,{inputElement:t})})}),T),(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(rC,{onLogIn:()=>this.loginViaPopup().catch(R=>U.warn(R.message))})})}),C)}(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Nb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(sd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ad(this.inputMediator.getSelection())),this.store.dispatch(qd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var T;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((T=this.state.conversation.current)==null?void 0:T.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&U.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(zT,{onLogIn:()=>this.loginViaPopup().catch(s=>U.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Yt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Nf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){ck(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>k(this,null,function*(){yield this.store.dispatch(ll());let t=or(this.state);t&&(yield this.store.dispatch(il()),this.store.dispatch(Qc({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return k(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",m),clearInterval(d)};i.onmessage=f=>k(this,null,function*(){var v,y;if((v=f.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=f.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(ja),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let m=f=>k(this,null,function*(){var v;if(f.origin===a.origin)switch((v=f.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(y,a.origin,[o.port2])}catch(y){U.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),f.data.message==="Timeout"&&U.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(f.data.message));break}}});window.addEventListener("message",m);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return k(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(U.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;U.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return k(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=zd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(cn()):nu.includes(r)||this.store.dispatch(fn(r))})}catch(r){this.handleError(r)}})}};bs.version="12.0.2-beta.0",bs.count=0;var Ml=bs;function bk(r,o){return k(this,arguments,function*(e,t,n={}){var m,d;let{value:i}=e,{start:s,end:a}=(m=n.replace)!=null?m:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function Ck(r,o){return k(this,arguments,function*(e,t,n={}){let i=n.replace?io(e,n.replace.start,n.replace.end):Ss(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
27
+ `);break}default:break}m&&s++}return l(e),a}var jT=(s=>(s.CUT="Cut",s.BACKSPACE="Backspace",s.DELETE="Delete",s.ERASEEOF="EraseEof",s.UNDO="Undo",s.CLEAR="Clear",s))(jT||{}),fr=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedHTML=this.getHTML(),this.cachedSelection=this.getSelection(),this.listen()}addEventListener(t,n){let r=o=>{n(o)};this.element.addEventListener(t,r),this.disposeHandlers.push(()=>{this.element.removeEventListener(t,r)})}removeEventListener(t,n){this.element.removeEventListener(t,n)}handleInteraction(){let t=this.getText(),n=this.getHTML(),r=this.getSelection(),o=this.getCaretPosition();this.isActive&&(t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit"),t!==this.cachedText&&(this.cachedText=t,this.cachedHTML=n,this.emit("change",{plainText:t,rawHTML:n})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,this.emit("selection",r)),$r(o,this.cachedCaretPosition)||(this.cachedCaretPosition=o,this.emit("caretposition",o)))}handleClick(){this.handleInteraction()}handleFocus(){let t=!this.isFocused;this.isFocused=!0,t&&this.emit("focus"),this.handleInteraction()}handleBlur(){this.isPossibleClearInputAction=!1;let t=this.isFocused;this.isFocused=!1,t&&this.emit("blur")}handleKeyDown(t){let{key:n,ctrlKey:r,metaKey:o}=t;this.isPossibleClearInputAction=Object.values(jT).includes(n)||n.toLowerCase()==="z"&&(r||o),this.emit("keydown",t)}handleKeyUp(t){this.handleInteraction(),this.emit("keyup",t)}handleCut(){this.isPossibleClearInputAction=!0,this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(t){var r,o;let n=((r=t.clipboardData)==null?void 0:r.getData("text"))||((o=t.clipboardData)==null?void 0:o.getData("text/plain"))||"";this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.handleInteraction()),this.addEventListener("change",()=>this.handleInteraction()),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.handleInteraction()),document.activeElement===this.element&&(this.isFocused=!0);let t=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});t.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{t.disconnect()})}focus(){this.element.focus()}emit(t,...n){this.isDisposed||this.eventListeners[t]&&this.eventListeners[t].forEach(r=>{r(...n)})}on(t,n){this.isDisposed||(this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n))}activate(){let t=this.isActive===!1;this.isActive=!0,t&&this.handleInteraction()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(t=>t()),this.eventListeners={},this.isDisposed=!0}};function VT(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Yo=class extends fr{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Ll(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){var s;let n=this.getRootNode();if(n.activeElement!==this.element)return null;let r="getSelection"in n?n.getSelection():window.getSelection();if(!r)return null;let o="getComposedRanges"in r&&n instanceof ShadowRoot?(s=r.getComposedRanges(n))==null?void 0:s[0]:r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let i=this.element.ownerDocument.createRange();return i.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),i.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!i||!this.element.contains(i.startContainer)||!this.element.contains(i.endContainer)?null:i}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!VT(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!VT(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Al(this.element,n);let r=this.lastKnownSelection;if(r&&BT(this.element,r.start,r.end))return r;let o=Ss(this.element);return o.collapse(!1),Al(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Ll(this.element,io(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(()=>{setTimeout(()=>{this.handleInteraction()},0)});n.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this.disposeHandlers.push(()=>n.disconnect());let r=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==r&&(r=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}};var Qo=class extends fr{constructor(){super(...arguments);this.lastKnownSelection=null}getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:n,selectionEnd:r}=this.element;return{start:n,end:r}}getSelectedText(){let n=this.getSelection();return n?this.getText().slice(n.start,n.end):""}getCaretPosition(){return null}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var i;return(i=n==null?void 0:n.get)==null?void 0:i.call(this.element)},set:i=>{var s;(s=n==null?void 0:n.set)==null||s.call(this.element,i),this.handleInteraction()}});let r=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==r&&(r=this.element.disabled,this.emit(r?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};function KT(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let i=document.createElement("iframe"),s=new URL(t);return Object.entries(n).forEach(([a,l])=>{s.searchParams.append(a,l)}),i.style.position="absolute",i.style.left="-999em",i.style.width="0px",i.style.height="0px",i.tabIndex=-1,i.id=r,i.title=`iframe-${e}`,i.src=s.toString(),window.document.body.appendChild(i),i}function $M(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var Cy=class{constructor(t){this.name=t;this.disposeHandlers=[];this.broadcastChannel=new BroadcastChannel(t)}onMessage(t){this.broadcastChannel.addEventListener("message",t),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",t)})}postMessage(t){this.broadcastChannel.postMessage(JSON.stringify(t))}close(){this.disposeHandlers.forEach(t=>t()),this.broadcastChannel.close()}},Ty=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=KT(t,`${this.targetOrigin}/sdk/proxy/proxy.html`,{channel:this.name,host:window.location.origin,debug:"1"}),document.body.appendChild(this.iframe)}onMessage(t){window.addEventListener("message",t),this.disposeHandlers.push(()=>{window.removeEventListener("message",t)})}postMessage(t){var n;(n=this.iframe.contentWindow)==null||n.postMessage(JSON.stringify(t),this.targetOrigin)}close(){var t;this.disposeHandlers.forEach(n=>n()),(t=this.iframe)==null||t.remove()}},ky=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.sessionId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setSessionId(t){this.sessionId!==t&&(this.cleanup(),z.info("Set sessionId",t),this.sessionId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new Ty(t,this.deepdeskUrl,{debug:!0}):new Cy(t),r=o=>{var s,a;if(o.origin!==this.deepdeskUrl)return;let i=$M(o.data);typeof i!="object"||i.type!=="event"||i.channel!==t||(z.info("Received broadcast event",this.sessionId,o),(a=(s=this.eventMap)[i.name])==null||a.call(s,i.payload))};return n.onMessage(r),n}send(t,n,r){var s,a;z.info("Broadcast event",{sessionId:this.sessionId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(s=this.eventMap)[t])==null||a.call(s,n));let i=this.sessionId==="deepdesk-general"?this.defaultChannel:this.channel;i==null||i.postMessage(O(P({},o),{channel:this.sessionId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),delete this.channel,t&&((r=this.defaultChannel)==null||r.close(),delete this.defaultChannel)}},WT=ky;var ws=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Py=e=>new Promise(t=>{setTimeout(t,e)});var xs=class extends ws{constructor(){super(...arguments);this.name="ClientError"}},Ay=class extends ws{constructor(){super(...arguments);this.name="ServerError"}},Ry=new Map;function qM(e){return k(this,null,function*(){var r;if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t&&t.includes("application/json"))return e.json();let n=yield e.text();if(n==="")return null;z.warn("Unexpected response body:",n.slice(0,20));try{e.status===200&&((r=window.Sentry)==null||r.captureMessage(n.slice(0,1e4)))}catch(o){z.error(o)}return JSON.parse(n)})}var so=class so{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.fetch=window.fetch.bind(window);n.fetch&&(this.fetch=n.fetch)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let i={isAborted:!1,reject:o},s=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:u=!1,abortLatest:c=!1,attempts:m=1,retryDelay:d=500,refreshTokenOn401:f=!0,retryOnError:v=R=>R instanceof TypeError,retryOnResponse:y=R=>R.status>=500,version:g="v1"}=C,p=te(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(u)if(l){if(Ry.has(s)){r(Ry.get(s));return}}else throw new Error(`Can't use 'useCache' for ${n.method}`);let h=O(P({credentials:"include"},p),{headers:P({"Content-Type":"application/json"},p.headers)});!l&&this.csrfToken&&(h.headers=O(P({},h.headers),{"X-CSRFToken":this.csrfToken})),typeof g=="string"&&(h.headers=O(P({},h.headers),{"X-Deepdesk-API-Version":g}));let S=m,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&c&&(this.latestRequestByUrl[s].isAborted=!0,this.latestRequestByUrl[s].reject(new Error("Aborted"))),this.latestRequestByUrl[s]=i;let T=()=>k(this,null,function*(){return S--,a(s,h).then(R=>k(this,null,function*(){return y(R)&&!i.isAborted&&S>0?(yield Py(d),T()):R.status===401&&f===!0&&x===!1?(x=!0,yield this.refreshToken(),T()):R})).catch(R=>k(this,null,function*(){if(v(R)&&!i.isAborted&&S>0)return yield Py(d),T();throw R}))});T().then(R=>k(this,null,function*(){let N=yield qM(R);if(delete this.latestRequestByUrl[s],R.status>=500){o(new Ay("Server Error",N));return}else if(R.status===401){o(new xs("Unauthorized",N));return}else if(R.status===403){o(new xs("Forbidden",N));return}else if(R.status===404){o(new xs("Not Found",N));return}else if(R.status>=400){o(new xs("Bad Request",N));return}u&&Ry.set(s,N),r(N)})).catch(R=>{o(R)})})}validateToken(){return k(this,null,function*(){let{has_valid_access_token:t}=yield this.get("/auth/validate");if(!t)return!1;let{is_logged_in:n}=yield this.get("/apis/admin/session/validate/",{version:null});return!!n})}refreshToken(){return so.refreshingToken||(so.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{so.refreshingToken=null},1e3*60)})),so.refreshingToken}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,P({method:"POST",body:JSON.stringify(n)},r))}patch(t,n,r){return this.request(t,P({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,P({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,P({method:"DELETE"},n))}};so.refreshingToken=null;var yn=so;var $T;(t=>{let e;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(e=t.EventType||(t.EventType={}))})($T||($T={}));function kf(e){return O(P({},re(e)),{tags:e.tags})}var Zo=class Zo{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new yn(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,i)=>k(this,null,function*(){let s=yield r(o,i);return this.handleDeepdeskVersionHeaders(s),s}))}preflight(){return k(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(Zo.exchangeTokenPromise||(Zo.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),Zo.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return k(this,null,function*(){yield this.preflight(),z.info(`Creating conversation for session ${t.sessionId} and agent ${t.agentId}`);let n=yield this.client.post("/api/conversations",O(P({},Ne(t)),{tags:t.tags}),{version:"v2"});return kf(n)})}getProfile(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{version:null,useCache:!0});return re(n)})}getKnowledgeAssistant(t){return k(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{version:null,useCache:!0});return re(n)})}getContentTypes(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{version:null,useCache:!0});return re(t)})}getAccount(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{version:null,useCache:!0});return re(t)})}getPlatformConfig(){return k(this,null,function*(){let{config:t}=yield this.client.get("/platform/config/",{version:null,useCache:!0});return re(t)})}checkUserExists(t){return k(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`);return n})}getConversationBySessionId(r){return k(this,arguments,function*(t,n={}){yield this.preflight(),z.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:i=1e3}=n,s=yield this.client.get(`/api/conversations/by_session_id/${t}`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return z.info(`Successfully retrieved conversation ${s.id} for session ${t}`),kf(s)})}isConversationSupported(r){return k(this,arguments,function*(t,n={}){z.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:i=1e3}=n;return(yield this.client.get(`/api/conversations/by_session_id/${t}/active_profile`,{attempts:o,retryDelay:i,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"})).has_active_profile})}updateConversation(t,n){return k(this,null,function*(){let r=Ne(n);n.tags&&(r.tags=n.tags);let o=yield this.client.put(`/api/conversations/${t}`,r,{version:"v2"});return kf(o)})}postMessages(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/messages`,n.map(o=>O(P({},Ne(o)),{tags:o.tags})),{version:"v2"})).map(o=>kf(o))})}sendEvent(t,n){return k(this,null,function*(){let s=n,{data:r}=s,o=te(s,["data"]),i=Object.entries(this.latestReceivedDeepdeskVersions).reduce((a,[l,u])=>O(P({},a),{[l]:u}),{});return this.client.post("/api/events",Ne(O(P(P({},i),o),{data:r,name:t})),{version:"v2"})})}sendEventV1(t,n){return k(this,null,function*(){let r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((o,[i,s])=>O(P({},o),{[i]:s}),{});return this.client.post("/api/events",{event:t,data:Ne(P(P({},n),r))})})}getEntities(t){return k(this,null,function*(){return(yield this.client.post("/api/entities",{messages:t.filter(r=>r.text)})).entities})}getSummary(r){return k(this,arguments,function*(t,n={}){let o=yield this.client.post("/api/summary",{conversation:{messages:t.filter(i=>i.text&&i.source),agent_id:n.agentId,id:n.externalConversationId},prompt_instruction:n.promptInstruction,model:n.model});return re(o)})}getTemporaryExchangeToken(){return k(this,null,function*(){return(yield this.client.get("/auth/exchange-token",{version:null})).jwt})}exchangeTokenForAccessCookie(t){return k(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t},{version:null}).catch(n=>{throw z.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return k(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Ne(n),{version:null,refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return k(this,arguments,function*(t,n={},r){return r==="sticky-messages"?this.getPinnedMessages(t):(yield this.client.post(`/api/conversations/${t}/recommend/${r}`,Ne(n),{abortLatest:!0})).map(s=>O(P({},re(s)),{text:s.text||s.url||s.message,source:r,type:r})).filter((s,a,l)=>a===l.findIndex(u=>u.text===s.text))})}isLoggedIn(){return k(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return k(this,null,function*(){return(yield this.client.post(`/api/conversations/${t}/autocomplete`,Ne(n),{abortLatest:!0})).map(o=>({score:1,source:o.source,sourceText:o.source_text,text:o.label,trainingJobs:o.training_jobs,searchKeywords:o.search_keywords,type:o.source})).filter((o,i,s)=>i===s.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/api/conversations/${t}/sticky-messages`,{abortLatest:!0});return re(n).map(r=>O(P({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return k(this,null,function*(){let n=yield this.client.post("/api/style-suggestions",Ne(t),{abortLatest:!0});return re(n)})}search(t){return k(this,null,function*(){let n=yield this.client.post(`/api/profiles/${t.profile}/search`,Ne(t),{version:"v2"});return re(n)})}knowledgeAssist(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=yield this.client.post(`/api/knowledge-assist/assistants/${r}/search`,Ne({question:t.question,doNotKnowAnswer:t.doNotKnowAnswer,customerInstruction:t.customerInstruction,chatHistory:n.map(u=>({question:u.question,answer:u.answer.answer})),agentId:o.agentId,conversationId:o.conversationId}),{version:"v2"});return re(l)})}requestLoginByEmail(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t},{version:null});return re(n)})}requestPasswordlessToken(){return k(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/",{version:null});return re(t.token)})}getCsrfToken(){return k(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/",{version:null});return t})}verifyLoginToken(t){return k(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t},{version:null});return re(n)})}evaluateRule(i,s,a){return k(this,arguments,function*(t,n,r,o={}){let l=new URLSearchParams;o.raiseForFailingConditions&&l.set("raise_for_failing_conditions","true");let u=yield this.client.post(`/api/conversations/${n}/rules/${t}/evaluate?${l.toString()}`,r,{version:"v2"});return u?re(u.cues):[]})}getRules(){return k(this,null,function*(){let t=new URLSearchParams,n=yield this.client.get(`/apis/admin/rule-engine/rules/?${t.toString()}`,{version:null,useCache:!0});return re(n)})}translateMessages(t){return k(this,null,function*(){let n=yield this.client.post("/api/translate",Ne(t),{version:"v2"});return re(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),i=o.match(qv);if(!n||!i)return;let s=i[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[s];a&&n&&a!==n&&z.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[s]=n})}};Zo.exchangeTokenPromise=null;var pr=Zo;var Il=class{constructor(t,n){this.url=t;this.eventListeners={};this.options=P({timeout:25e3},n)}proxyEvent(t){this.eventSource.addEventListener(Jg(t),n=>{let{data:r}=n;try{let o=JSON.parse(r);this.emit(t,re(o))}catch(o){z.warn(`Invalid JSON for ${t}: ${r}`)}})}connect(){clearTimeout(this.timeoutTimer);let t=new EventSource(this.url,{withCredentials:!0});this.eventSource=t;let n=!1;t.onopen=()=>{n=!0},t.onerror=()=>{n&&t.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{t.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(r=>{this.proxyEvent(r)})}disconnect(){var t;clearTimeout(this.timeoutTimer),this.eventListeners={},(t=this.eventSource)==null||t.close()}emit(t,n){this.eventListeners[t]&&this.eventListeners[t].forEach(r=>r(n))}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),this.proxyEvent(t),()=>{this.off(t,n)}}off(t,n){let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}};var qT;(t=>{let e;(i=>(i.Started="Started",i.Aborted="Aborted",i.Completed="Completed"))(e=t.AutoflowSessionState||(t.AutoflowSessionState={}))})(qT||(qT={}));var Nl=class{constructor(t,n={}){this.apiUrl=t;this.streams={};this.logger=z;this.client=new yn(t,n)}getCustomMessages(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/suggestions`);return re(n.suggestions)})}sendCustomMessage(t,n){return k(this,null,function*(){let r=yield this.client.post(`/sessions/${t}/messages`,Ne(n));return re(r)})}answerCustomMessage(t,n){return k(this,null,function*(){yield this.client.post(`/sessions/${t}/answers`,Ne(n))})}getAutoflows(t){return k(this,null,function*(){let n=yield this.client.get(`/sessions/${t}/autoflows`);return re(n.autoflows)})}startAutoflowSession(t){return k(this,null,function*(){let n=yield this.client.post("/autoflow-sessions",Ne(t));return re(n)})}stopAutoflowSession(t){return k(this,null,function*(){yield this.client.delete(`/autoflow-sessions/${t}`)})}openStream(t){return this.streams[t]||(this.streams[t]=new Il(`${this.apiUrl}/sessions/${t}/events`),this.streams[t].connect()),this.streams[t]}closeStream(t){this.streams[t]||(this.streams[t].disconnect(),delete this.streams[t])}};var GT={startTime:null,stopTime:null},XT=Q({name:"handlingTime",initialState:GT,reducers:{handlingTimeStart(e){if(e.startTime&&!e.stopTime)throw new Error("Timing already started");e.startTime=new Date,e.stopTime=null},handlingTimeStop(e){if(!e.startTime)throw new Error("Timing not started");e.stopTime=new Date},handlingTimeReset(e){e.startTime=null,e.stopTime=null}},extraReducers:e=>{e.addCase(fe,()=>GT)}}),{handlingTimeStart:YT,handlingTimeStop:Pf,handlingTimeReset:QT}=XT.actions,ZT=XT.reducer;var JT=(e={})=>{let t=P({onAuthError:Qi(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var Rf={list:{keywordMatches:[]},fetchState:"idle"};var Jo=K("styleSuggestions/getAll",(n,r)=>k(void 0,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,i=t.getState(),{showStyleSuggestions:s}=i.settings,a=(l=i.conversation.current)==null?void 0:l.profileCode;if(!s)return Rf.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),GM=Q({name:"styleSuggestions",initialState:Rf,reducers:{},extraReducers:e=>{e.addCase(Jo.pending,t=>{t.fetchState="loading"}).addCase(Jo.rejected,t=>{t.fetchState="error"}).addCase(Jo.fulfilled,(t,n)=>{t.fetchState="done",$r(t.list,n.payload)||(t.list=n.payload)}).addCase(Io,t=>{t.list=Rf.list}).addCase(fe,()=>Rf)}}),ek=GM.reducer;var tk=(e={})=>{let t,n=!0,r=P({getStyleSuggestions:Jo,debounce:500},e);return o=>i=>s=>{var f;let a=o.getState().input.text,l=i(s),u=o.getState();if(u.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:c}=u.settings;if(!((f=u.conversation.current)==null?void 0:f.id)||!c)return l;let{text:d}=u.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function XM(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end}var nk=(e={})=>{let t=P({getTextSuggestions:fn,getAutocompleteSuggestions:ul,debounce:200,check:Rn},e),n;return r=>o=>i=>{var y;let{input:s}=r.getState(),a=o(i),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:u,showTabCompletion:c}=l.settings,m=(y=l.conversation.current)==null?void 0:y.id,d=i.type===jd.toString();if(!m||!u&&!c)return a;let{input:f}=l;return XM(f,s)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let g=es(l);g===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(g))},d?0:t.debounce)),a}};var rk=Jo.fulfilled.toString();function YM(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let i=e.keywordMatches.filter(l=>l.keyword===o),s=t.keywordMatches.filter(l=>l.keyword===o),a=s.length-i.length;a<=0||r.push(...s.slice(0,a))}),r}var ok=e=>t=>n=>r=>{var u;if(r.type!==rk){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let i=t.getState(),s=i.styleSuggestions.list,a=(u=i.conversation)==null?void 0:u.current;if(o===s)return;let l=YM(o,s);r.type===rk&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var QM=Ec({answer:ub,auth:p1,autoflows:LC,conversation:b1,contentTypes:SE,customMessages:UC,passwordlessToken:jC,entities:KE,knowledgeAssistant:sb,handlingTime:ZT,info:B1,input:_1,settings:s1,profile:pb,search:G1,summary:QE,styleSuggestions:ek,ui:jb,rules:qC,textSuggestions:xb});function ik(e){return fx({reducer:QM,middleware:t=>[...t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI,deepdeskBrokerAPI:e.deepdeskBrokerAPI}},serializableCheck:!1}),JT(),nk({debounce:200}),tk({debounce:500}),ok(e.deepdeskAPI),...e.middleware?e.middleware:[]],preloadedState:e.preloadedState})}var ZM=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},JM=e=>t=>n=>r=>{var a,l,u,c,m,d;let o=t.getState(),i=qg("inlineSuggestions")(o);switch(r.type){case Qi.toString():{!r.payload&&e.emit("logout",void 0);break}case cn.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(a=o.conversation.current)==null?void 0:a.id,data:{entities:r.payload}});break;case ot.toString():e.sendEvent(r.payload.name,{conversationId:((l=r.payload.options)==null?void 0:l.includeConversationData)&&((u=o.conversation.current)==null?void 0:u.id),data:r.payload.data});break;case Io.toString():e.logSendMessage(r.payload);break;case Go.fulfilled.toString():r.isBroadcasted||e.broadcast(nh,r,!1),(c=r.payload.options)!=null&&c.shouldEmit&&e.emit("cues",r.payload.cues);break;default:break}let s=n(r);switch(r.type){case Io.toString():e.handleAfterSendMessage(r.payload);break;case dl.toString():e.onUpdateShowTabHint(r.payload);break;case Pf.toString():e.logHandlingTime();break;case"analytics/logEvent/fulfilled":{e.emit("event",r.meta.arg);break}case rd.toString():{let{start:f,end:v}=o.input.selection;e.emit("replace",O(P({},r.payload),{replace:r.payload.replace==="selection"?{start:f,end:v}:{start:0,end:v}}));break}case rn.toString():{let{start:f,end:v}=o.input.selection;e.emit("select-suggestion",O(P({type:ZM(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:f,end:v}:{start:0,end:v}})),i&&t.dispatch(Xn([]));break}case od.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(m=o.conversation.current)==null?void 0:m.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Xn.toString():{i&&r.payload.length>0&&t.dispatch(id(0));break}case tr.fulfilled.toString():{e.sendEvent("conversation summarized",{conversationId:(d=o.conversation.current)==null?void 0:d.id,data:{summary:r.payload.summary,model:t.getState().summary.model}});break}default:break}return s},sk=JM;function Ly(e){return e.toISOString().replace("T"," ").replace("Z","")}function ak(e,t){var i,s,a,l;let n=(i=e.conversation.current)==null?void 0:i.id;if(!n)return z.warn("No conversationId for handling time metrics"),null;let{startTime:r,stopTime:o}=e.handlingTime;return!r||!o?(z.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:n,clientVersion:t.version,agentId:(s=e.info.agentInfo)==null?void 0:s.agentId,agentName:(a=e.info.agentInfo)==null?void 0:a.agentName,agentEmail:(l=e.info.agentInfo)==null?void 0:l.agentEmail,timeStart:Ly(r),timeStop:Ly(o)}}function lk(e,t,n){var N,_,D,G;let r=(N=t.conversation.current)==null?void 0:N.id;if(!r)return z.warn("No conversationId for send message metrics"),null;let{text:o,metrics:{numCharsTyped:i,numCharsPasted:s,numCharsCut:a,numCharsDeleted:l,numPaste:u,agentStartedTypingTimestamp:c,externalTimeTotalSeconds:m,pastes:d,cuts:f,deletions:v,textSuggestions:y,offeredTextSuggestions:g}}=t[e],p=o.length,S=y.reduce((Z,{text:se,searchTerm:mr})=>Z+se.length-(mr?mr.length:0),0),x=c!=null?c:Date.now(),T=(Date.now()-x)/1e3+(m||0),C=i/T,R=y.reduce((Z,{searchTerm:se})=>Z+(se?se.length:0),0);return{conversationId:r,source:"agent",text:o,clientVersion:n.version,pastes:d,cuts:f,deletions:v,lenTextTyped:i+R,lenTextTotal:p,lenTextAssisted:S,lenTextPasted:s,lenTextCut:a,lenTextDeleted:l,timeTotalSeconds:T,charsPerSecond:C,numPastes:u,textSuggestionsV2:y,suggestionsCounters:[{source:"gpt",countOffered:g.filter(Z=>Z.source==="gpt").length}],agentId:(_=t.info.agentInfo)==null?void 0:_.agentId,agentName:(D=t.info.agentInfo)==null?void 0:D.agentName,agentEmail:(G=t.info.agentInfo)==null?void 0:G.agentEmail}}function Iy(e,t){var i;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return Iy(r,t);let o=(i=e.ownerDocument.defaultView)==null?void 0:i.frameElement;return o?Iy(o,t):null}function uk(e,t){return Iy(e,t)}function ck(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function e2(e){return typeof e=="object"&&e!==null&&"tagName"in e}function Af(e){return e2(e)&&(to(e)||Jd(e))}var fk,Nn=new Map,t2=["bottom","height","left","right","top","width"],dk=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:t2.some(n=>e[n]!==t[n]);function pk(e){var n,r,o;if(e.ownerDocument===document)return[];let t=(o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement)!=null?o:null;return t?[t,...pk(t)]:[]}function mk(e,t){return!e||!t?null:O(P({},e),{top:e.top+t.top,left:e.left+t.left})}var Lf=!1,gk=()=>{Lf=!0;let e=[];if(Nn.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),Nn.delete(n);return}let r=n.getBoundingClientRect();dk(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(mk,t.rect):t.rect;dk(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),Nn.size===0){Lf=!1;return}fk=window.requestAnimationFrame(gk)};function Ny(e,t){let n=pk(e),r=[],o=n.map((i,s)=>Ny(i,a=>{r[s]=a;let l=Nn.get(e);if(!l)return;let u=r.reduce(mk,l.rect);l.callbacks.forEach(c=>c(u))}));return{observe(i=!0){if(o.forEach(s=>s.observe(!1)),Nn.has(e)){let s=Nn.get(e);s.callbacks.push(t),s.rect&&t(s.rect)}else Nn.set(e,{rect:void 0,callbacks:[t],parentRects:r});i&&!Lf&&gk()},unobserve(){o.forEach(s=>s.unobserve());let i=Nn.get(e);if(i){let s=i.callbacks.indexOf(t);s>=0&&i.callbacks.splice(s,1),i.callbacks.length||Nn.delete(e),Nn.size||(cancelAnimationFrame(fk),Lf=!1)}}}}var hk,On=new Map,yk=()=>{On.forEach((e,t)=>{if(!t.isConnected){On.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(i=>i(e.visible)))}),On.size!==0&&(hk=window.requestAnimationFrame(yk))};function vk(e,t){return{observe(){let n=On.size===0;On.has(e)?On.get(e).callbacks.push(t):On.set(e,{visible:void 0,callbacks:[t]}),n&&yk()},unobserve(){let n=On.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||On.delete(e),On.size||cancelAnimationFrame(hk)}}}}var Oy=["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 My(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function Es(e){return parseFloat(e)}function If(e){return Math.round(e*1e6)}function Sk(e){return e/1e6}function _y(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=Es(e.width),i=Es(e.borderLeftWidth),s=Es(e.borderRightWidth),a=Es(e.paddingRight),l=Sk(If(o)-If(i)-If(s)),u=Sk(If(r));if(l-u>2){let c=l-u;n.style.paddingRight=`${a+c}px`}}function Ol(e,t={}){var c,m;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(c=t.position)!=null?c:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",Wo(n);let r=window.getComputedStyle(e),o=!0,i=()=>{n.scrollTop=e.scrollTop};My(r,n,Oy),_y(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",i));let s=vk(e,()=>{My(r,n,Oy),_y(r,e,n),i(),setTimeout(i,0)}),a,l=!0,u=Ny(e,d=>{if(d===null){t.onRemove&&t.onRemove(),n.remove();return}if(!l&&t.onMoveStart&&(Promise.resolve().then(()=>t.onMoveStart()),l=!0),clearTimeout(a),a=setTimeout(()=>{t.onMoveEnd&&t.onMoveEnd(),l=!1},200),d.height===0&&d.width===0){if(o===!0)return;t.onHide&&t.onHide(),n.style.display="none",o=!0;return}if(My(r,n,Oy),_y(r,e,n),i(),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let f=t.closestScrollElement.getBoundingClientRect(),v=window.getComputedStyle(t.closestScrollElement),y=Es(v.borderTopWidth),g=Es(v.borderBottomWidth),p=f.top+y-d.top,h=d.top+d.height+-(f.top+f.height-g);n.style.clipPath=`inset(${p}px 0px ${h}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(m=e.parentElement)==null||m.appendChild(n),u.observe(),s.observe(),[n,()=>{e.removeEventListener("scroll",i),u.unobserve(),s.unobserve()}]}var wk=(e,t)=>({value(){try{let n=sessionStorage.getItem(`dd-${e}`);if(!n)return t;try{return JSON.parse(n)}catch(r){return t}}catch(n){return t}},update(n){try{sessionStorage.setItem(`dd-${e}`,JSON.stringify(n))}catch(r){z.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function n2(e){return e.offsetParent!==null}function xk(e){if(!n2(e))return!1;let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}function Nf(e,t,n=100){let r=xk(e);t({isVisible:r});let o=setInterval(()=>{let i=xk(e);i!==r&&(r=i,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var _e=w(b());var Ek=wk("showTabHint",!0),bs=class bs{constructor({deepdeskUrl:t,brokerUrl:n,version:r=bs.version||"unknown",locale:o="en-US",token:i,fetch:s,productName:a,createCustomChannel:l}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.widgetRoot=null;this.dynamicThunkObject={};this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let u=t.replace(/\/api$/,"");this.deepdeskApi=new pr(u,{token:i,fetch:s}),this.version=r,this.instanceId=bs.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[sk({broadcast:(m,d,f)=>{this.broadcastEvents.send(m,d,f)},emit:(m,d)=>this.emit(m,d),handleAfterSendMessage:m=>this.handleAfterSendMessage(m),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:m=>this.logSendMessage(m),onUpdateShowTabHint:m=>Ek.update(m),sendEvent:(m,d)=>this.deepdeskApi.sendEvent(m,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new Nl(n)}),this.store=ik(c),this.broadcastEvents=new WT({debug:!0,deepdeskUrl:u,eventMap:X1(this.store),createCustomChannel:l}),this.store.dispatch(dl(Ek.value())),this.store.dispatch(Qc({locale:o,adminUrl:u,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex])!=null?t: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?(z.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(z.warn("Profile has not been loaded (yet)"),!0):(z.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(Qi(null)),this.store.dispatch(qn()),new Promise(t=>{let n=this.store.subscribe(()=>{let r=this.store.getState();rt(r)&&a1(r)!=="loading"&&(n(),t())});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return k(this,null,function*(){return(yield this.store.dispatch(qn())).payload})}setPlatformAgentId(t){return k(this,null,function*(){try{if((yield this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;yield this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:t}),version:null})}catch(n){z.warn("Failed to attach user:",n)}})}isConversationSupported(t,n){return k(this,null,function*(){return(yield this.store.dispatch(Yg({sessionId:t,options:n}))).payload})}createConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(Jc(t))).payload})}getConversationBySessionId(t,n){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t&&this.resetConversation(),(yield this.store.dispatch(ed({sessionId:t,options:n}))).payload})}upsertConversation(t){return k(this,null,function*(){return this.hasConversation()&&this.sessionId()!==t.sessionId&&this.resetConversation(),(yield this.store.dispatch(Qg(t))).payload})}postMessages(t){return k(this,null,function*(){return(yield this.store.dispatch(nd(t))).payload})}updateConversation(t){return k(this,null,function*(){return(yield this.store.dispatch(td(t))).payload})}resetConversation(){this.store.dispatch(fe()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}getSummary(){return k(this,null,function*(){let t=yield this.store.dispatch(tr());if(t.error)throw new Error(t.error.message);return t.payload.summary})}configure(t){this.store.dispatch(Qc(t))}setVisitorInfo(t){this.store.dispatch(U1(t))}setCustomData(t){this.store.dispatch(z1(t))}setAgentInfo(t){return k(this,null,function*(){yield this.store.dispatch(za(t))})}setAgentSettings(t){return k(this,null,function*(){yield this.store.dispatch(eh(t))})}getAgentSettings(){return k(this,null,function*(){return(yield this.store.dispatch(th())).payload})}refresh(){return k(this,null,function*(){if(this.shouldAbort())return Promise.resolve();this.inputMediator&&this.store.dispatch(sd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()}));let t=[];return this.store.dispatch(jd()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}notifyExternalSuggestion(t){this.store.dispatch(rn(t))}evaluateRule(o){return k(this,arguments,function*(t,n={},r=VC){return(yield this.store.dispatch(Go({label:t,params:n,options:r}))).payload.cues})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:i,selection:s}=this.state.input,{inlineSuggestions:a,showTextSuggestions:l}=this.state.settings,u=a?"below":"above",c=o.length>0;if(!Rn(this.state)||(this.store.dispatch(R1(Zg(t))),t.key!=="Tab"&&!l))return;let m=()=>{n||!c||s&&(t.shiftKey||(this.store.dispatch(I1()),t.preventDefault()))},d=()=>{n||!c||a&&i<=0||s&&(t.shiftKey||(this.store.dispatch(N1()),t.preventDefault()))};switch(t.key){case"ArrowUp":u==="below"?d():m();break;case"ArrowDown":{u==="below"?m():d();break}case"Escape":{n||(this.store.dispatch(id(-1)),this.store.dispatch(Jr({collapse:!0})),this.store.dispatch(zb(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let f=ts(this.state);if(!f)return;this.store.dispatch(dl(!1)),this.store.dispatch(rn({text:f.text,suggestion:f,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(this.state.settings.inlineSuggestions||this.state.input.selectedSuggestionIndex===-1)return;let f=ts(this.state);if(!f)return;this.store.dispatch(rn({text:f.text,suggestion:f,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(this.state.settings.inlineSuggestions||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let f=ts(this.state);if(!f)return;this.store.dispatch(rn({text:f.text,suggestion:f,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(Jr({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Xn([]))}handlingTimeStart(){this.state.handlingTime.startTime||(z.info("Start handling time"),this.store.dispatch(YT()))}handlingTimeStop(){this.state.handlingTime.startTime&&(z.info("Stop handling time"),this.store.dispatch(Pf()))}logSendMessage(t){let n=lk("input",this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n))}logHandlingTime(){let t=ak(this.state,{version:this.version});t&&(this.deepdeskApi.sendEventV1("Handling Time",t),this.store.dispatch(QT()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Io((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(M1()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(i){z.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),z.error(i)}})}on(t,n){return this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].push(n),()=>{this.off(t,n)}}off(t,n){if(!t&&!n){this.eventListeners={};return}let r;this.eventListeners[t]&&(r=this.eventListeners[t].indexOf(n),r>-1&&this.eventListeners[t].splice(r,1))}setConversationQuery(t){this.dynamicThunkObject.conversationQuery=t}whenConversationLoaded(t){let n=()=>this.loadProfileConfig().then(()=>t());this.hasConversation()&&n();let r=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==r&&(r=this.hasConversation(),r&&n())})}overlayContainerFactory(t,n,r,o){let[i,s]=Ol(n,r);return i.setAttribute("translate","no"),i.dataset.testid=t,o&&i.classList.add(o),this.unmountHandlers.push(()=>{(0,Yt.unmountComponentAtNode)(i),s(),i.remove()}),i}createInlineContainer(t,n){var a;let r=document.createElement("div");r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.height="0px",r.style.width="0px";let o=document.createElement("div");o.style.display="none",o.style.position="absolute",o.style.height="0px",o.style.width="0px",o.style.backgroundColor="red",r.appendChild(o);let i=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,s=i.ownerDocument.defaultView;if(i&&(s===window||(s==null?void 0:s.parent)===window)){let[l,u]=Ol(i,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{(0,Yt.unmountComponentAtNode)(o),u()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return Wo(o),o.dataset.testid=t,o.style.color=r.color,o.style.fontSize=r.fontSize,o.style.fontFamily=r.fontFamily,o.style.fontVariant=r.fontVariant,o.setAttribute("translate","no"),n.appendChild(o),this.unmountHandlers.push(()=>{(0,Yt.unmountComponentAtNode)(o),o.remove()}),o}storeMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=JSON.stringify({text:this.state.input.text,metrics:this.state.input.metrics});window.sessionStorage.setItem(t,n),z.info(`Stored analytics for ${this.conversationId()}`)}catch(t){}}restoreMetrics(){try{let t=`dd-metrics-${this.conversationId()}`,n=window.sessionStorage.getItem(t);if(!n)return;let r=JSON.parse(n);r.text.trim()===this.state.input.text.trim()?(z.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(O1(r.metrics))):z.warn(`Metrics mismatch, disregarding stored metrics for ${this.conversationId()}`),window.sessionStorage.removeItem(t)}catch(t){}}mount(t,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Af(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:r={},showStyleSuggestions:o,showTabCompletion:i,showTextSuggestions:s,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,isEmbedded:m,detectSubmit:d,insertLink:f,inputMediator:v,closestScrollSelector:y,appendOverlayTo:g,inlineSuggestions:p,floatingMenu:h}=n;this.configure({showStyleSuggestions:o,showTabCompletion:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:u,showSuggestionsAfterPattern:c,showTextSuggestions:s,insertLink:f,isEmbedded:m,inlineSuggestions:p,floatingMenu:!!h}),n.automaticHandlingTime&&this.setupHandlingTime(t),Wo(t),this.inputMediator=v||(to(t)?new Qo(t):new Yo(t)),this.inputMediator.on("change",({plainText:T,rawHTML:C})=>{this.store.dispatch(sd({text:T,html:C}))}),this.inputMediator.on("keyup",T=>{this.store.dispatch(A1(Zg(T)))}),this.inputMediator.on("keydown",T=>{this.handleKeyDown(T)}),this.inputMediator.on("paste",({pastedText:T,selectionText:C})=>{this.store.dispatch(L1({text:T,selectionText:C}))}),this.inputMediator.on("cut",({selectionText:T})=>{this.store.dispatch(P1(T))});let S;this.inputMediator.on("selection",T=>{clearTimeout(S),T===null?S=setTimeout(()=>{T!==null&&this.store.dispatch(ad(T))},500):this.store.dispatch(ad(T))}),this.inputMediator.on("disabled",()=>{var T;(T=this.inputMediator)==null||T.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{d&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(qd(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(qd(!0))});let x=y&&uk(t,y)||void 0;if(p){let{customStyles:T,appendOverlayTo:C}=n;if(to(t))throw new Error("[Deepdesk] Inline suggestion is not supported for textarea yet.");let R=this.createInlineContainer(t,"deepdesk-caret");(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:T,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Gb,{})})}),R),this.inputMediator.on("caretposition",_=>{this.store.dispatch(Xn([])),_?(R.style.display="block",R.style.top=`${_.top}px`,R.style.left=`${_.left}px`):R.style.display="none"});let N=this.overlayContainerFactory("floating-menu",x||t,{appendTo:typeof h=="object"&&"appendOverlayTo"in h?h.appendOverlayTo:C},T==null?void 0:T.floatingMenuRootNode);(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:T,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Fb,{onLogIn:()=>this.loginViaPopup().catch(_=>z.warn(_.message))})})}),N)}else{let T=this.overlayContainerFactory("deepdesk-tab-completion",x||t,{appendTo:g,closestScrollElement:x,mirrorOverflow:!0,onRemove:()=>this.unmount()},r==null?void 0:r.rootNode),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",x||t,{appendTo:g},r==null?void 0:r.suggestionsRootNode);(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(CC,{inputElement:t})})}),T),(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(rC,{onLogIn:()=>this.loginViaPopup().catch(R=>z.warn(R.message))})})}),C)}(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(Nb,{})})}),this.createContainer("deepdesk-overlays")),this.store.dispatch(sd({text:this.inputMediator.getText(),html:this.inputMediator.getHTML()})),this.store.dispatch(ad(this.inputMediator.getSelection())),this.store.dispatch(qd(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{var T;this.restoreMetrics(),this.refresh(),this.broadcastEvents.setSessionId((T=this.state.conversation.current)==null?void 0:T.sessionId)}),this.isMounted=!0}unmount(){var t;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(t=this.inputMediator)==null||t.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(t,n={}){if(this.widgetRoot&&z.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:i}=n;this.widgetRoot=t,this.configure({showImages:o,isEmbedded:i}),(0,Yt.render)((0,_e.jsx)(qo,{store:this.store,customStyles:r,children:(0,_e.jsx)(Oo,{broadcastEvents:this.broadcastEvents,children:(0,_e.jsx)(zT,{onLogIn:()=>this.loginViaPopup().catch(s=>z.warn(s.message))})})}),t),this.whenConversationLoaded(()=>{var s;this.broadcastEvents.setSessionId((s=this.state.conversation.current)==null?void 0:s.sessionId)})}unmountWidget(){this.widgetRoot&&(0,Yt.unmountComponentAtNode)(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(t){let n=Nf(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){ck(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(()=>k(this,null,function*(){yield this.store.dispatch(ll());let t=or(this.state);t&&(yield this.store.dispatch(il()),this.store.dispatch(Qc({showSearch:t.search,showAutoflows:t.autoflows,showCustomMessages:t.customMessages,showImageSearch:t.imageSearch,showEntitiesCommand:t.entitiesCommand,showSummaryCommand:t.summarizer,showKnowledgeSearch:!!t.knowledgeAssistant,recommendTextSuggestions:t.recommendTextSuggestions})))})),this.loadProfileConfigPromise)}loginViaPopup(t){return k(this,null,function*(){return new Promise((n,r)=>{let o=new MessageChannel,i=o.port1,s=this.state.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${s}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,u=()=>{c&&!c.closed&&c.close(),window.removeEventListener("message",m),clearInterval(d)};i.onmessage=f=>k(this,null,function*(){var v,y;if((v=f.data)!=null&&v.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=f.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(ja),l=!0,o.port1.close(),n()}catch(g){console.error(g),r(g)}finally{l=!0,u()}});let c=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");c===null&&r(new Error("Popup blocked by browser"));let m=f=>k(this,null,function*(){var v;if(f.origin===a.origin)switch((v=f.data)==null?void 0:v.type){case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});c==null||c.postMessage(y,a.origin,[o.port2])}catch(y){z.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{u(),f.data.message==="Timeout"&&z.warn("Popup timed out. Check if the account's platform url is configured correctly."),r(new Error(f.data.message));break}}});window.addEventListener("message",m);let d=setInterval(()=>{c&&!c.closed||(u(),l||r(new Error("Popup closed by user")))},200);this.unmountHandlers.push(u)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}checkForTrialMode(t){return k(this,null,function*(){try{let{account:n}=yield this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(z.info("Trial is active"),!(yield this.deepdeskApi.checkUserExists(t)))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:r}=n;z.info(r),this.shouldRender=!1}})}refreshWidgetSuggestions(){return k(this,null,function*(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=zd(this.state);try{n.forEach(({type:r})=>{r==="entities"?this.store.dispatch(cn()):nu.includes(r)||this.store.dispatch(fn(r))})}catch(r){this.handleError(r)}})}};bs.version="12.0.2-beta.2",bs.count=0;var Ml=bs;function bk(r,o){return k(this,arguments,function*(e,t,n={}){var m,d;let{value:i}=e,{start:s,end:a}=(m=n.replace)!=null?m:{start:0,end:i.length},l=`${i.slice(0,s)}${t}${i.slice(a)}`,u=(d=n.selectionAfter)!=null?d:{start:s+t.length,end:s+t.length},c=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(c()).then(()=>{e.selectionStart=u.start,e.selectionEnd=u.end,e.blur(),e.focus()})})}function Ck(r,o){return k(this,arguments,function*(e,t,n={}){let i=n.replace?io(e,n.replace.start,n.replace.end):Ss(e),s,a=()=>{if(n.setRange)return n.setRange(i.cloneRange());i.deleteContents(),s=document.createElement("span"),i.insertNode(s),n.insertBRs!==!1?t.split(`
28
28
  `).reverse().forEach((l,u)=>{u>0&&i.insertNode(document.createElement("br")),i.insertNode(document.createTextNode(l))}):i.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?io(e,n.selectionAfter.start,n.selectionAfter.end):(i.collapse(!1),i),u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(l)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function r2(e){let t=document.createElement("template");return t.innerHTML=e.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3" target="_blank" rel="noopener noreferrer">$2</a>'),t.content}function o2(e){let t=document.createDocumentFragment();return e.split(`
29
29
  `).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},i=0;for(;o=n.slice(i).match(/(\[([^\]]+)])\(([^)]+)\)/);){let s=document.createElement("a");s.href=o[3],s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer"),s.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(i,i+o.index))),t.appendChild(s),i=i+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(i)))}),t}function Tk(e,t){let n=e.parentElement;if(!n){console.warn("No insert point found");return}let{display:r}=window.getComputedStyle(n);r.includes("block")||r==="table-cell"?n==null||n.insertBefore(t,e.nextSibling):Tk(n,t)}function kk(o,i){return k(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let s;e.dispatchEvent(new InputEvent("beforeinput",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0}));let a=()=>{var d;let l=(d=e.ownerDocument.defaultView)!=null?d:window,u=l.getSelection();if((!u||u.rangeCount===0)&&(e.focus(),u=l.getSelection()),!u||u.rangeCount===0)return;let c=u.getRangeAt(0);if(!c)return;s=document.createElement("span"),c.insertNode(s);let m=r?r2(t):o2(t);n?Tk(c.startContainer,m):(c.insertNode(m),c.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!s)try{s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})})}function Pk(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function Rk(e,t,n){return k(this,null,function*(){yield new pr(e).authenticateWithKey(t,n)})}function Ak(e){return k(this,null,function*(){let n=yield new yn(e).get("/platform/config/",{version:null,useCache:!0});return re(n)})}function i2(e){return k(this,null,function*(){var o,i,s;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(s=(i=e.mimeType)!=null?i:n.headers.get("Content-Type"))!=null?s:"image/jpeg"})})}function Lk(e,t){return k(this,null,function*(){let n=yield i2(t),r=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(e,"files",{configurable:!0,get:()=>[n]}),e.dispatchEvent(r)}finally{Object.hasOwn(e,"files")&&delete e.files}})}return $k(s2);})();
30
30
  /*! Bundled license information: