@deepdesk/deepdesk-sdk 19.6.1 → 19.6.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.iife.js +2 -2
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -9,7 +9,7 @@ Error generating stack: `+s.message+`
|
|
|
9
9
|
The error may be correlated with this previous error:
|
|
10
10
|
${nt.current.stack}
|
|
11
11
|
|
|
12
|
-
`),oe}nd(()=>{nt.current=void 0,te.current=void 0,re.current=Oe});let yt=ce.useMemo(()=>ce.createElement(S,I(b({},Oe),{ref:L})),[L,S,Oe]);return ce.useMemo(()=>h?ce.createElement(V.Provider,{value:j},yt):yt,[V,yt,j])}let C=ce.memo(x);if(C.WrappedComponent=S,C.displayName=x.displayName=m,l){let P=ce.forwardRef(function(D,V){return ce.createElement(C,I(b({},D),{reactReduxForwardedRef:V}))});return P.displayName=m,P.WrappedComponent=S,Bg(P,S)}return Bg(C,S)}}var Mw=qO;function YO(e){let{children:t,context:n,serverState:r,store:o}=e,s=ce.useMemo(()=>{let l=Iw(o);return{store:o,subscription:l,getServerState:r?()=>r:void 0}},[o,r]),i=ce.useMemo(()=>o.getState(),[o]);return nd(()=>{let{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),i!==o.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,i]),ce.createElement((n||Xr).Provider,{value:s},t)}var Ow=YO;function Wg(e=Xr){return function(){return ce.useContext(e)}}var Lw=Wg();function Nw(e=Xr){let t=e===Xr?Lw:Wg(e),n=()=>{let{store:r}=t();return r};return Object.assign(n,{withTypes:()=>n}),n}var XO=Nw();function QO(e=Xr){let t=e===Xr?XO:Nw(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var we=QO(),ZO=(e,t)=>e===t;function JO(e=Xr){let t=e===Xr?Lw:Wg(e),n=(r,o={})=>{let{equalityFn:s=ZO}=typeof o=="function"?{equalityFn:o}:o,i=t(),{store:a,subscription:l,getServerState:c}=i,u=ce.useRef(!0),f=ce.useCallback({[r.name](p){return r(p)}}[r.name],[r]),d=(0,Dw.useSyncExternalStoreWithSelector)(l.addNestedSub,a.getState,c||a.getState,f,s);return ce.useDebugValue(d),d};return Object.assign(n,{withTypes:()=>n}),n}var K=JO();function Ct(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var eL=typeof Symbol=="function"&&Symbol.observable||"@@observable",Fw=eL,$g=()=>Math.random().toString(36).substring(7).split("").join("."),tL={INIT:`@@redux/INIT${$g()}`,REPLACE:`@@redux/REPLACE${$g()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${$g()}`},rd=tL;function od(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function jg(e,t,n){if(typeof e!="function")throw new Error(Ct(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ct(0));if(typeof t=="function"&&typeof n=="undefined"&&(n=t,t=void 0),typeof n!="undefined"){if(typeof n!="function")throw new Error(Ct(1));return n(jg)(e,t)}let r=e,o=t,s=new Map,i=s,a=0,l=!1;function c(){i===s&&(i=new Map,s.forEach((S,g)=>{i.set(g,S)}))}function u(){if(l)throw new Error(Ct(3));return o}function f(S){if(typeof S!="function")throw new Error(Ct(4));if(l)throw new Error(Ct(5));let g=!0;c();let m=a++;return i.set(m,S),function(){if(g){if(l)throw new Error(Ct(6));g=!1,c(),i.delete(m),s=null}}}function d(S){if(!od(S))throw new Error(Ct(7));if(typeof S.type=="undefined")throw new Error(Ct(8));if(typeof S.type!="string")throw new Error(Ct(17));if(l)throw new Error(Ct(9));try{l=!0,o=r(o,S)}finally{l=!1}return(s=i).forEach(m=>{m()}),S}function p(S){if(typeof S!="function")throw new Error(Ct(10));r=S,d({type:rd.REPLACE})}function h(){let S=f;return{subscribe(g){if(typeof g!="object"||g===null)throw new Error(Ct(11));function m(){let x=g;x.next&&x.next(u())}return m(),{unsubscribe:S(m)}},[Fw](){return this}}}return d({type:rd.INIT}),{dispatch:d,subscribe:f,getState:u,replaceReducer:p,[Fw]:h}}function nL(e){Object.keys(e).forEach(t=>{let n=e[t];if(typeof n(void 0,{type:rd.INIT})=="undefined")throw new Error(Ct(12));if(typeof n(void 0,{type:rd.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error(Ct(13))})}function sd(e){let t=Object.keys(e),n={};for(let i=0;i<t.length;i++){let a=t[i];typeof e[a]=="function"&&(n[a]=e[a])}let r=Object.keys(n),o,s;try{nL(n)}catch(i){s=i}return function(a={},l){if(s)throw s;let c=!1,u={};for(let f=0;f<r.length;f++){let d=r[f],p=n[d],h=a[d],y=p(h,l);if(typeof y=="undefined"){let S=l&&l.type;throw new Error(Ct(14))}u[d]=y,c=c||y!==h}return c=c||r.length!==Object.keys(a).length,c?u:a}}function pl(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function zw(...e){return t=>(n,r)=>{let o=t(n,r),s=()=>{throw new Error(Ct(15))},i={getState:o.getState,dispatch:(l,...c)=>s(l,...c)},a=e.map(l=>l(i));return s=pl(...a)(o.dispatch),I(b({},o),{dispatch:s})}}function Hw(e){return od(e)&&"type"in e&&typeof e.type=="string"}var qw=Symbol.for("immer-nothing"),Bw=Symbol.for("immer-draftable"),Dt=Symbol.for("immer-state");function rr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Cn=Object,Wi=Cn.getPrototypeOf,cd="constructor",gd="prototype",Yg="configurable",ud="enumerable",ad="writable",ml="value",Rr=e=>!!e&&!!e[Dt];function Tn(e){var t;return e?Yw(e)||yd(e)||!!e[Bw]||!!((t=e[cd])!=null&&t[Bw])||vd(e)||Sd(e):!1}var rL=Cn[gd][cd].toString(),Uw=new WeakMap;function Yw(e){if(!e||!rh(e))return!1;let t=Wi(e);if(t===null||t===Cn[gd])return!0;let n=Cn.hasOwnProperty.call(t,cd)&&t[cd];if(n===Object)return!0;if(!Vi(n))return!1;let r=Uw.get(n);return r===void 0&&(r=Function.toString.call(n),Uw.set(n,r)),r===rL}function hd(e,t,n=!0){yl(e)===0?(n?Reflect.ownKeys(e):Cn.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((r,o)=>t(o,r,e))}function yl(e){let t=e[Dt];return t?t.type_:yd(e)?1:vd(e)?2:Sd(e)?3:0}var Kg=(e,t,n=yl(e))=>n===2?e.has(t):Cn[gd].hasOwnProperty.call(e,t),Xg=(e,t,n=yl(e))=>n===2?e.get(t):e[t],dd=(e,t,n,r=yl(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function oL(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var yd=Array.isArray,vd=e=>e instanceof Map,Sd=e=>e instanceof Set,rh=e=>typeof e=="object",Vi=e=>typeof e=="function",Gg=e=>typeof e=="boolean";function sL(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Qr=e=>e.copy_||e.base_;var oh=e=>e.modified_?e.copy_:e.base_;function Qg(e,t){if(vd(e))return new Map(e);if(Sd(e))return new Set(e);if(yd(e))return Array[gd].slice.call(e);let n=Yw(e);if(t===!0||t==="class_only"&&!n){let r=Cn.getOwnPropertyDescriptors(e);delete r[Dt];let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++){let i=o[s],a=r[i];a[ad]===!1&&(a[ad]=!0,a[Yg]=!0),(a.get||a.set)&&(r[i]={[Yg]:!0,[ad]:!0,[ud]:a[ud],[ml]:e[i]})}return Cn.create(Wi(e),r)}else{let r=Wi(e);if(r!==null&&n)return b({},e);let o=Cn.create(r);return Cn.assign(o,e)}}function sh(e,t=!1){return xd(e)||Rr(e)||!Tn(e)||(yl(e)>1&&Cn.defineProperties(e,{set:id,add:id,clear:id,delete:id}),Cn.freeze(e),t&&hd(e,(n,r)=>{sh(r,!0)},!1)),e}function iL(){rr(2)}var id={[ml]:iL};function xd(e){return e===null||!rh(e)?!0:Cn.isFrozen(e)}var fd="MapSet",Zg="Patches",Vw="ArrayMethods",Xw={};function Ms(e){let t=Xw[e];return t||rr(0,e),t}var Ww=e=>!!Xw[e];var gl,Qw=()=>gl,aL=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ww(fd)?Ms(fd):void 0,arrayMethodsPlugin_:Ww(Vw)?Ms(Vw):void 0});function $w(e,t){t&&(e.patchPlugin_=Ms(Zg),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Jg(e){eh(e),e.drafts_.forEach(lL),e.drafts_=null}function eh(e){e===gl&&(gl=e.parent_)}var jw=e=>gl=aL(gl,e);function lL(e){let t=e[Dt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Kw(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[Dt].modified_&&(Jg(t),rr(4)),Tn(e)&&(e=Gw(t,e));let{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(n[Dt].base_,e,t)}else e=Gw(t,n);return cL(t,e,!0),Jg(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==qw?e:void 0}function Gw(e,t){if(xd(t))return t;let n=t[Dt];if(!n)return pd(t,e.handledSet_,e);if(!wd(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);eb(n,e)}return n.copy_}function cL(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&sh(t,n)}function Zw(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var wd=(e,t)=>e.scope_===t,uL=[];function Jw(e,t,n,r){var a;let o=Qr(e),s=e.type_;if(r!==void 0&&Xg(o,r,s)===t){dd(o,r,n,s);return}if(!e.draftLocations_){let l=e.draftLocations_=new Map;hd(o,(c,u)=>{if(Rr(u)){let f=l.get(u)||[];f.push(c),l.set(u,f)}})}let i=(a=e.draftLocations_.get(t))!=null?a:uL;for(let l of i)dd(o,l,n,s)}function dL(e,t,n){e.callbacks_.push(function(o){var a,l;let s=t;if(!s||!wd(s,o))return;(a=o.mapSetPlugin_)==null||a.fixSetContents(s);let i=oh(s);Jw(e,(l=s.draft_)!=null?l:s,i,n),eb(s,o)})}function eb(e,t){var r,o;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||((o=(r=e.assigned_)==null?void 0:r.size)!=null?o:0)>0)){let{patchPlugin_:s}=t;if(s){let i=s.getPath(e);i&&s.generatePatches_(e,i,t)}Zw(e)}}function fL(e,t,n){let{scope_:r}=e;if(Rr(n)){let o=n[Dt];wd(o,r)&&o.callbacks_.push(function(){ld(e);let i=oh(o);Jw(e,n,i,t)})}else Tn(n)&&e.callbacks_.push(function(){var i;let s=Qr(e);e.type_===3?s.has(n)&&pd(n,r.handledSet_,r):Xg(s,t,e.type_)===n&&r.drafts_.length>1&&((i=e.assigned_.get(t))!=null?i:!1)===!0&&e.copy_&&pd(Xg(e.copy_,t,e.type_),r.handledSet_,r)})}function pd(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Rr(e)||t.has(e)||!Tn(e)||xd(e)||(t.add(e),hd(e,(r,o)=>{if(Rr(o)){let s=o[Dt];if(wd(s,n)){let i=oh(s);dd(e,r,i,e.type_),Zw(s)}}else Tn(o)&&pd(o,t,n)})),e}function pL(e,t){let n=yd(e),r={type_:n?1:0,scope_:t?t.scope_:Qw(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},o=r,s=md;n&&(o=[r],s=hl);let{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,[a,r]}var md={get(e,t){if(t===Dt)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let o=Qr(e);if(!Kg(o,t,e.type_))return gL(e,o,t);let s=o[t];if(e.finalized_||!Tn(s)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&sL(t))return s;if(s===qg(e.base_,t)||mL(e,t,s)){ld(e);let i=e.type_===1?+t:t,a=nh(e.scope_,s,e,i);return e.copy_[i]=a}return s},has(e,t){return t in Qr(e)},ownKeys(e){return Reflect.ownKeys(Qr(e))},set(e,t,n){let r=tb(Qr(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let o=qg(Qr(e),t),s=o==null?void 0:o[Dt];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(oL(n,o)&&(n!==void 0||Kg(e.base_,t,e.type_)))return!0;ld(e),th(e)}return e.copy_[t]===n&&(n!==void 0||Kg(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),fL(e,t,n)),!0},deleteProperty(e,t){return ld(e),qg(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),th(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Qr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[ad]:!0,[Yg]:e.type_!==1||t!=="length",[ud]:r[ud],[ml]:n[t]}},defineProperty(){rr(11)},getPrototypeOf(e){return Wi(e.base_)},setPrototypeOf(){rr(12)}},hl={};for(let e in md){let t=md[e];hl[e]=function(){let n=arguments;return n[0]=n[0][0],t.apply(this,n)}}hl.deleteProperty=function(e,t){return hl.set.call(this,e,t,void 0)};hl.set=function(e,t,n){return md.set.call(this,e[0],t,n,e[0])};function qg(e,t){let n=e[Dt];return(n?Qr(n):e)[t]}function mL(e,t,n){var r;return e.type_!==1||!e.allIndicesReassigned_||(r=e.assigned_)!=null&&r.get(t)||!Tn(n)||n[Dt]?!1:e.baseRefs_.has(n)}function gL(e,t,n){var o;let r=tb(t,n);return r?ml in r?r[ml]:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function tb(e,t){if(!(t in e))return;let n=Wi(e);for(;n;){let r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Wi(n)}}function th(e){e.modified_||(e.modified_=!0,e.parent_&&th(e.parent_))}function ld(e){e.copy_||(e.assigned_=new Map,e.copy_=Qg(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var hL=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Vi(t)&&!Vi(n)){let s=n;n=t;let i=this;return function(l=s,...c){return i.produce(l,u=>n.call(this,u,...c))}}Vi(n)||rr(6),r!==void 0&&!Vi(r)&&rr(7);let o;if(Tn(t)){let s=jw(this),i=nh(s,t,void 0),a=!0;try{o=n(i),a=!1}finally{a?Jg(s):eh(s)}return $w(s,r),Kw(o,s)}else if(!t||!rh(t)){if(o=n(t),o===void 0&&(o=t),o===qw&&(o=void 0),this.autoFreeze_&&sh(o,!0),r){let s=[],i=[];Ms(Zg).generateReplacementPatches_(t,o,{patches_:s,inversePatches_:i}),r(s,i)}return o}else rr(1,t)},this.produceWithPatches=(t,n)=>{if(Vi(t))return(i,...a)=>this.produceWithPatches(i,l=>t(l,...a));let r,o;return[this.produce(t,n,(i,a)=>{r=i,o=a}),r,o]},Gg(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Gg(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Gg(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Tn(e)||rr(8),Rr(e)&&(e=nb(e));let t=jw(this),n=nh(t,e,void 0);return n[Dt].isManual_=!0,eh(t),n}finishDraft(e,t){let n=e&&e[Dt];(!n||!n.isManual_)&&rr(9);let{scope_:r}=n;return $w(r,t),Kw(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));let r=Ms(Zg).applyPatches_;return Rr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function nh(e,t,n,r){var a,l;let[o,s]=vd(t)?Ms(fd).proxyMap_(t,n):Sd(t)?Ms(fd).proxySet_(t,n):pL(t,n);return((a=n==null?void 0:n.scope_)!=null?a:Qw()).drafts_.push(o),s.callbacks_=(l=n==null?void 0:n.callbacks_)!=null?l:[],s.key_=r,n&&r!==void 0?dL(n,s,r):s.callbacks_.push(function(u){var d;(d=u.mapSetPlugin_)==null||d.fixSetContents(s);let{patchPlugin_:f}=u;s.modified_&&f&&f.generatePatches_(s,[],u)}),o}function nb(e){return Rr(e)||rr(10,e),rb(e)}function rb(e){if(!Tn(e)||xd(e))return e;let t=e[Dt],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Qg(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Qg(e,!0);return hd(n,(o,s)=>{dd(n,o,rb(s))},r),t&&(t.finalized_=!1),n}var yL=new hL,ih=yL.produce;function vL(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function SL(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){let n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var ob=e=>Array.isArray(e)?e:[e];function xL(e){let t=Array.isArray(e[0])?e[0]:e;return SL(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function wL(e,t){let n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var bL=class{constructor(e){this.value=e}deref(){return this.value}},EL=()=>typeof WeakRef=="undefined"?bL:WeakRef,ib=EL(),CL=0,sb=1;function bd(){return{s:CL,v:void 0,o:null,p:null}}function TL(e){return e instanceof ib?e.deref():e}function ab(e,t={}){let n=bd(),{resultEqualityCheck:r}=t,o,s=0;function i(){let a=n,{length:l}=arguments;for(let f=0,d=l;f<d;f++){let p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let h=a.o;h===null&&(a.o=h=new WeakMap);let y=h.get(p);y===void 0?(a=bd(),h.set(p,a)):a=y}else{let h=a.p;h===null&&(a.p=h=new Map);let y=h.get(p);y===void 0?(a=bd(),h.set(p,a)):a=y}}let c=a,u;if(a.s===sb)u=a.v;else if(u=e.apply(null,arguments),s++,r){let f=TL(o);f!=null&&r(f,u)&&(u=f,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new ib(u):u}return c.s=sb,c.v=u,u}return i.clearCache=()=>{n=bd(),i.resetResultsCount()},i.resultsCount=()=>s,i.resetResultsCount=()=>{s=0},i}function kL(e,...t){let n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...o)=>{let s=0,i=0,a,l={},c=o.pop();typeof c=="object"&&(l=c,c=o.pop()),vL(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);let u=b(b({},n),l),{memoize:f,memoizeOptions:d=[],argsMemoize:p=ab,argsMemoizeOptions:h=[]}=u,y=ob(d),S=ob(h),g=xL(o),m=f(function(){return s++,c.apply(null,arguments)},...y),v=!0,x=p(function(){i++;let C=wL(g,arguments);return a=m.apply(null,C),a},...S);return Object.assign(x,{resultFunc:c,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>a,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var un=kL(ab);function lb(e){return({dispatch:n,getState:r})=>o=>s=>typeof s=="function"?s(n,r,e):o(s)}var cb=lb(),ub=lb;var RL=typeof window!="undefined"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pl:pl.apply(null,arguments)},q8=typeof window!="undefined"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}},PL=e=>e&&typeof e.match=="function";function Tt(e,t){function n(...r){if(t){let o=t(...r);if(!o)throw new Error(Zr(0));return b(b({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Hw(r)&&r.type===e,n}var gb=class vl extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,vl.prototype)}static get[Symbol.species](){return vl}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new vl(...t[0].concat(this)):new vl(...t.concat(this))}};function db(e){return Tn(e)?ih(e,()=>{}):e}function Ed(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function AL(e){return typeof e=="boolean"}var IL=()=>function(t){let{thunk:n=!0,immutableCheck:r=!0,serializableCheck:o=!0,actionCreatorCheck:s=!0}=t!=null?t:{},i=new gb;return n&&(AL(n)?i.push(cb):i.push(ub(n.extraArgument))),i},_L="RTK_autoBatch";var fb=e=>t=>{setTimeout(t,e)},ML=(e,t)=>n=>{let r=!1,o=()=>{r||(r=!0,cancelAnimationFrame(s),clearTimeout(i),n())},s=e(o),i=setTimeout(o,t)},OL=(e={type:"raf"})=>t=>(...n)=>{let r=t(...n),o=!0,s=!1,i=!1,a=new Set,l=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window!="undefined"&&window.requestAnimationFrame?ML(window.requestAnimationFrame,100):fb(10):e.type==="callback"?e.queueNotification:fb(e.timeout),c=()=>{i=!1,s&&(s=!1,a.forEach(u=>u()))};return Object.assign({},r,{subscribe(u){let f=()=>o&&u(),d=r.subscribe(f);return a.add(u),()=>{d(),a.delete(u)}},dispatch(u){var f;try{return o=!((f=u==null?void 0:u.meta)!=null&&f[_L]),s=!o,s&&(i||(i=!0,l(c))),r.dispatch(u)}finally{o=!0}}})},LL=e=>function(n){let{autoBatch:r=!0}=n!=null?n:{},o=new gb(e);return r&&o.push(OL(typeof r=="object"?r:void 0)),o};function hb(e){let t=IL(),{reducer:n=void 0,middleware:r,devTools:o=!0,duplicateMiddlewareCheck:s=!0,preloadedState:i=void 0,enhancers:a=void 0}=e||{},l;if(typeof n=="function")l=n;else if(od(n))l=sd(n);else throw new Error(Zr(1));let c;typeof r=="function"?c=r(t):c=t();let u=pl;o&&(u=RL(b({trace:!1},typeof o=="object"&&o)));let f=zw(...c),d=LL(f),p=typeof a=="function"?a(d):d(),h=u(...p);return jg(l,i,h)}function yb(e){let t={},n=[],r,o={addCase(s,i){let a=typeof s=="string"?s:s.type;if(!a)throw new Error(Zr(28));if(a in t)throw new Error(Zr(29));return t[a]=i,o},addAsyncThunk(s,i){return i.pending&&(t[s.pending.type]=i.pending),i.rejected&&(t[s.rejected.type]=i.rejected),i.fulfilled&&(t[s.fulfilled.type]=i.fulfilled),i.settled&&n.push({matcher:s.settled,reducer:i.settled}),o},addMatcher(s,i){return n.push({matcher:s,reducer:i}),o},addDefaultCase(s){return r=s,o}};return e(o),[t,n,r]}function NL(e){return typeof e=="function"}function DL(e,t){let[n,r,o]=yb(t),s;if(NL(e))s=()=>db(e());else{let a=db(e);s=()=>a}function i(a=s(),l){let c=[n[l.type],...r.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[o]),c.reduce((u,f)=>{if(f)if(Rr(u)){let p=f(u,l);return p===void 0?u:p}else{if(Tn(u))return ih(u,d=>f(d,l));{let d=f(u,l);if(d===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return d}}return u},a)}return i.getInitialState=s,i}var FL=(e,t)=>PL(e)?e.match(t):e(t);function zL(...e){return t=>e.some(n=>FL(n,t))}var HL="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",BL=(e=21)=>{let t="",n=e;for(;n--;)t+=HL[Math.random()*64|0];return t},UL=["name","message","stack","code"],ah=class{constructor(e,t){xe(this,"payload");xe(this,"meta");xe(this,"_type");this.payload=e,this.meta=t}},pb=class{constructor(e,t){xe(this,"payload");xe(this,"meta");xe(this,"_type");this.payload=e,this.meta=t}},VL=e=>{if(typeof e=="object"&&e!==null){let t={};for(let n of UL)typeof e[n]=="string"&&(t[n]=e[n]);return t}return{message:String(e)}},mb="External signal was aborted",he=(()=>{function e(t,n,r){let o=Tt(t+"/fulfilled",(l,c,u,f)=>({payload:l,meta:I(b({},f||{}),{arg:u,requestId:c,requestStatus:"fulfilled"})})),s=Tt(t+"/pending",(l,c,u)=>({payload:void 0,meta:I(b({},u||{}),{arg:c,requestId:l,requestStatus:"pending"})})),i=Tt(t+"/rejected",(l,c,u,f,d)=>({payload:f,error:(r&&r.serializeError||VL)(l||"Rejected"),meta:I(b({},d||{}),{arg:u,requestId:c,rejectedWithValue:!!f,requestStatus:"rejected",aborted:(l==null?void 0:l.name)==="AbortError",condition:(l==null?void 0:l.name)==="ConditionError"})}));function a(l,{signal:c}={}){return(u,f,d)=>{let p=r!=null&&r.idGenerator?r.idGenerator(l):BL(),h=new AbortController,y,S;function g(v){S=v,h.abort()}c&&(c.aborted?g(mb):c.addEventListener("abort",()=>g(mb),{once:!0}));let m=(function(){return _(this,null,function*(){var T,C;let v;try{let k=(T=r==null?void 0:r.condition)==null?void 0:T.call(r,l,{getState:f,extra:d});if($L(k)&&(k=yield k),k===!1||h.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let P=new Promise((L,D)=>{y=()=>{D({name:"AbortError",message:S||"Aborted"})},h.signal.addEventListener("abort",y,{once:!0})});u(s(p,l,(C=r==null?void 0:r.getPendingMeta)==null?void 0:C.call(r,{requestId:p,arg:l},{getState:f,extra:d}))),v=yield Promise.race([P,Promise.resolve(n(l,{dispatch:u,getState:f,extra:d,requestId:p,signal:h.signal,abort:g,rejectWithValue:((L,D)=>new ah(L,D)),fulfillWithValue:((L,D)=>new pb(L,D))})).then(L=>{if(L instanceof ah)throw L;return L instanceof pb?o(L.payload,p,l,L.meta):o(L,p,l)})])}catch(k){v=k instanceof ah?i(null,p,l,k.payload,k.meta):i(k,p,l)}finally{y&&h.signal.removeEventListener("abort",y)}return r&&!r.dispatchConditionRejection&&i.match(v)&&v.meta.condition||u(v),v})})();return Object.assign(m,{abort:g,requestId:p,arg:l,unwrap(){return m.then(WL)}})}}return Object.assign(a,{pending:s,rejected:i,fulfilled:o,settled:zL(i,o),typePrefix:t})}return e.withTypes=()=>e,e})();function WL(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function $L(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var vb=Symbol.for("rtk-slice-createasyncthunk"),X8={[vb]:he};function jL(e,t){return`${e}/${t}`}function KL({creators:e}={}){var n;let t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[vb];return function(o){let{name:s,reducerPath:i=s}=o;if(!s)throw new Error(Zr(11));let a=(typeof o.reducers=="function"?o.reducers(qL()):o.reducers)||{},l=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(x,T){let C=typeof x=="string"?x:x.type;if(!C)throw new Error(Zr(12));if(C in c.sliceCaseReducersByType)throw new Error(Zr(13));return c.sliceCaseReducersByType[C]=T,u},addMatcher(x,T){return c.sliceMatchers.push({matcher:x,reducer:T}),u},exposeAction(x,T){return c.actionCreators[x]=T,u},exposeCaseReducer(x,T){return c.sliceCaseReducersByName[x]=T,u}};l.forEach(x=>{let T=a[x],C={reducerName:x,type:jL(s,x),createNotation:typeof o.reducers=="function"};XL(T)?ZL(C,T,u,t):YL(C,T,u)});function f(){let[x={},T=[],C=void 0]=typeof o.extraReducers=="function"?yb(o.extraReducers):[o.extraReducers],k=b(b({},x),c.sliceCaseReducersByType);return DL(o.initialState,P=>{for(let L in k)P.addCase(L,k[L]);for(let L of c.sliceMatchers)P.addMatcher(L.matcher,L.reducer);for(let L of T)P.addMatcher(L.matcher,L.reducer);C&&P.addDefaultCase(C)})}let d=x=>x,p=new Map,h=new WeakMap,y;function S(x,T){return y||(y=f()),y(x,T)}function g(){return y||(y=f()),y.getInitialState()}function m(x,T=!1){function C(P){let L=P[x];return typeof L=="undefined"&&T&&(L=Ed(h,C,g)),L}function k(P=d){let L=Ed(p,T,()=>new WeakMap);return Ed(L,P,()=>{var V;let D={};for(let[ne,Y]of Object.entries((V=o.selectors)!=null?V:{}))D[ne]=GL(Y,P,()=>Ed(h,P,g),T);return D})}return{reducerPath:x,getSelectors:k,get selectors(){return k(C)},selectSlice:C}}let v=I(b({name:s,reducer:S,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:g},m(i)),{injectInto(x,k={}){var P=k,{reducerPath:T}=P,C=ie(P,["reducerPath"]);let L=T!=null?T:i;return x.inject({reducerPath:L,reducer:S},C),b(b({},v),m(L,!0))}});return v}}function GL(e,t,n,r){function o(s,...i){let a=t(s);return typeof a=="undefined"&&r&&(a=n()),e(a,...i)}return o.unwrapped=e,o}var Re=KL();function qL(){function e(t,n){return b({_reducerDefinitionType:"asyncThunk",payloadCreator:t},n)}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function YL({type:e,reducerName:t,createNotation:n},r,o){let s,i;if("reducer"in r){if(n&&!QL(r))throw new Error(Zr(17));s=r.reducer,i=r.prepare}else s=r;o.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,i?Tt(e,i):Tt(e))}function XL(e){return e._reducerDefinitionType==="asyncThunk"}function QL(e){return e._reducerDefinitionType==="reducerWithPrepare"}function ZL({type:e,reducerName:t},n,r,o){if(!o)throw new Error(Zr(18));let{payloadCreator:s,fulfilled:i,pending:a,rejected:l,settled:c,options:u}=n,f=o(e,s,u);r.exposeAction(t,f),i&&r.addCase(f.fulfilled,i),a&&r.addCase(f.pending,a),l&&r.addCase(f.rejected,l),c&&r.addMatcher(f.settled,c),r.exposeCaseReducer(t,{fulfilled:i||Cd,pending:a||Cd,rejected:l||Cd,settled:c||Cd})}function Cd(){}var Sb="listener",xb="completed",wb="cancelled",Q8=`task-${wb}`,Z8=`task-${xb}`,J8=`${Sb}-${wb}`,eH=`${Sb}-${xb}`;var{assign:bb}=Object;var lh="listenerMiddleware";var JL=bb(Tt(`${lh}/add`),{withTypes:()=>JL}),tH=Tt(`${lh}/removeAll`),eN=bb(Tt(`${lh}/remove`),{withTypes:()=>eN});function Zr(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Sl=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Sl||{});var tN={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},kt=e=>e.auth.isLoggedIn;var Eb=e=>e.auth.verifyFetchState,Cb=e=>e.auth.showLoginOverlay,Tb=e=>e.auth.loginError,Jr=he("auth/validate",(e,t)=>_(null,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),kb=he("auth/requestLogin",(n,r)=>_(null,[n,r],function*({email:e},t){let{deepdeskAPI:o}=t.extra;return o.requestLoginByEmail(e)})),ch=he("auth/loginWithPassword",(r,o)=>_(null,[r,o],function*({username:e,password:t},n){let{deepdeskAPI:s}=n.extra;return s.loginWithPassword(e,t)})),Td=he("auth/logout",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra;yield n.logout()})),xl=he("auth/verifyLoginToken",(n,r)=>_(null,[n,r],function*({token:e},t){let{deepdeskAPI:o}=t.extra;return o.verifyLoginToken(e)})),Rb=Re({name:"auth",initialState:tN,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload},setLoginError(e,t){e.loginError=t.payload},clearLoginError(e){e.loginError=null}},extraReducers:e=>{e.addCase(Jr.pending,t=>{t.loginFetchState="loading"}),e.addCase(Jr.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Jr.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ch.pending,t=>{t.loginFetchState="loading",t.loginError=null}),e.addCase(ch.fulfilled,t=>{t.isLoggedIn=!0,t.loginFetchState="done",t.loginError=null,t.showLoginOverlay=!1}),e.addCase(ch.rejected,(t,n)=>{t.loginFetchState="error",t.isLoggedIn=!1,t.loginError=n.error.message==="Bad Request"?"Invalid credentials":"Login failed"}),e.addCase(Td.fulfilled,t=>{t.isLoggedIn=!1,t.loginFetchState="idle",t.loginError=null}),e.addCase(Td.rejected,t=>{t.isLoggedIn=!1,t.loginFetchState="error"}),e.addCase(xl.pending,t=>{t.verifyFetchState="loading"}),e.addCase(xl.rejected,t=>{t.verifyFetchState="error"}),e.addCase(xl.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:$i,setShowLoginOverlay:Pb,setLoginError:uh,clearLoginError:kd}=Rb.actions,Ab=Rb.reducer;var wl=class{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);let s=this.castInput(t,r),i=this.castInput(n,r),a=this.removeEmpty(this.tokenize(s,r)),l=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(a,l,r,o)}diffWithOptionsObj(t,n,r,o){var s;let i=m=>{if(m=this.postProcess(m,r),o){setTimeout(function(){o(m)},0);return}else return m},a=n.length,l=t.length,c=1,u=a+l;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));let f=(s=r.timeout)!==null&&s!==void 0?s:1/0,d=Date.now()+f,p=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(p[0],n,t,0,r);if(p[0].oldPos+1>=l&&h+1>=a)return i(this.buildValues(p[0].lastComponent,n,t));let y=-1/0,S=1/0,g=()=>{for(let m=Math.max(y,-c);m<=Math.min(S,c);m+=2){let v,x=p[m-1],T=p[m+1];x&&(p[m-1]=void 0);let C=!1;if(T){let P=T.oldPos-m;C=T&&0<=P&&P<a}let k=x&&x.oldPos+1<l;if(!C&&!k){p[m]=void 0;continue}if(!k||C&&x.oldPos<T.oldPos?v=this.addToPath(T,!0,!1,0,r):v=this.addToPath(x,!1,!0,1,r),h=this.extractCommon(v,n,t,m,r),v.oldPos+1>=l&&h+1>=a)return i(this.buildValues(v.lastComponent,n,t))||!0;p[m]=v,v.oldPos+1>=l&&(S=Math.min(S,m-1)),h+1>=a&&(y=Math.max(y,m+1))}c++};if(o)(function m(){setTimeout(function(){if(c>u||Date.now()>d)return o(void 0);g()||m()},0)})();else for(;c<=u&&Date.now()<=d;){let m=g();if(m)return m}}addToPath(t,n,r,o,s){let i=t.lastComponent;return i&&!s.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}}extractCommon(t,n,r,o,s){let i=n.length,a=r.length,l=t.oldPos,c=l-o,u=0;for(;c+1<i&&l+1<a&&this.equals(r[l+1],n[c+1],s);)c++,l++,u++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!s.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=l,c}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let o=[],s;for(;t;)o.push(t),s=t.previousComponent,delete t.previousComponent,t=s;o.reverse();let i=o.length,a=0,l=0,c=0;for(;a<i;a++){let u=o[a];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let f=n.slice(l,l+u.count);f=f.map(function(d,p){let h=r[c+p];return h.length>d.length?h:d}),u.value=this.join(f)}else u.value=this.join(n.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return o}};var dh=class extends wl{},Ib=new dh;function fh(e,t,n){return Ib.diff(e,t,n)}function _b(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function zo(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((s,i)=>zo(s,t[i],n-1)):_b(e)&&_b(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(i=>zo(e[i],t[i],n-1)):!1}function nN(e){return Math.max(...e.map(t=>t.length))}function rN(e,t){let n=e.reduce((r,o)=>{if(o){let s=r[o]?r[o]+1:1;return I(b({},r),{[o]:s})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function Mb(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<nN(r);o++){let s=rN(r.map(a=>a[o]),t),i=r.filter(a=>!s.includes(a[o]));if(i.length>=t)r=i;else return{text:r[0].slice(0,o).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var oN=2;function Ob(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=Mb(e,oN);return n&&n.text!==t?n:e[0]}var sN={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},J=sN;var Lb={current:null,isSupported:null},ut=Tt("resetConversation"),Rd=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.externalId)||null},Pr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},ji=e=>e.conversation.isSupported,ph=he("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.externalId,e.options)}),Pd=he("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),Ad=he("conversation/byExternalId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationByExternalId(e.externalId,e.options)}),Id=he("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=Pr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),mh=he("conversation/upsert",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.upsertConversation(e)}),gh=he("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=Pr(t.getState());if(!r)throw new Error("No current conversation to update messages");return n.postMessages(r,e.map(o=>b({},o)))}),iN=[Pd.rejected,Ad.rejected,Id.rejected,gh.rejected].map(e=>e==null?void 0:e.toString());function aN(e){return iN.includes(e.type)}var lN=Re({name:"conversation",initialState:Lb,reducers:{},extraReducers:e=>{e.addCase(ph.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(Pd.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Ad.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(mh.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Id.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(ut,()=>Lb).addMatcher(aN,(t,n)=>{var r;throw J.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),Nb=lN.reducer;var Os={text:"",html:null,suggestionTextStart:0,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function hh(e){let{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:s}=e;return{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:s}}var _d=Tt("input/applyImageSuggestion"),Db=Re({name:"input",initialState:Os,reducers:{setInput(e,t){var i,a;let{beforeInputChange:n}=e,{text:r,html:o,suggestionTextStart:s}=t.payload;if(e.text=r,e.html=o!=null?o:null,e.suggestionTextStart=r===""?0:Math.max(0,s!=null?s:0),r==="")e.metrics=Os.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:l,shiftKey:c,ctrlKey:u,metaKey:f,altKey:d}=n.keyDown;switch(l){case"Enter":c&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=e,h=fh(n.text,p);n.text.length-p.length>1&&e.metrics.deletions.push(...h.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=n.text.length-p.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(u||f)break;default:if(!u&&!f&&!d){e.metrics.numCharsTyped+=1;let p=((i=n.selection)==null?void 0:i.start)!==void 0&&((a=n.selection)==null?void 0:a.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;p&&p.length>0&&(e.metrics.numCharsDeleted+=p.length,e.metrics.deletions.push(p))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},sendMessage(e,t){e.pinnedSuggestions=e.pinnedSuggestions.filter(n=>!e.metrics.textSuggestions.some(r=>r.text===n.text&&r.source===n.source))},setSelection(e,t){t.payload!==null&&(zo(e.selection,t.payload)||(e.selection=t.payload))},commitSuggestion(e,t){let n=t.payload,{text:r,suggestion:{source:o,abVariant:s,abTestName:i,trainingJobs:a,sourceText:l,searchTerm:c,assistantCode:u,text:f},eventMetrics:{inputType:d},replace:p}=n,h=o==="search"||o==="personal-collection-search",y=r.slice(e.text.substring(0,e.selection.start).length);(h||p==="selection")&&(y=r),n.suggestion.source==="search-overlay"&&(y=f),e.metrics.textSuggestions.push({text:y,source:o,assistantCode:u,abVariant:s,abTestName:i,inputType:d,sourceText:l,trainingJobs:a||[],searchTerm:h?e.text:c}),e.textSuggestions=[],e.selectedSuggestionIndex=-1},offeredTextSuggestion(e,t){let{text:n,suggestion:{source:r}}=t.payload;e.metrics.offeredTextSuggestions.find(s=>s.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=I(b({},e.metrics),{numCharsCut:n.numCharsCut+r.length,cuts:[...n.cuts,r]})},registerPaste(e,t){let{metrics:n}=e,{text:r,selectionText:o}=t.payload,s=n.numCharsDeleted+(o!=null&&o.length?o.length:0),i=o!=null&&o.length?[...n.deletions,o]:n.deletions;e.metrics=I(b({},e.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+r.length,numPaste:n.numPaste+1,pastes:[...n.pastes,r]})},selectNextTextSuggestion(e){let t=e.textSuggestions.length+e.pinnedSuggestions.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=Ls({input:e}),r=Ob(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setPinnedSuggestions(e,t){e.pinnedSuggestions=t.payload},removePinnedSuggestions(e,t){e.pinnedSuggestions=e.pinnedSuggestions.filter(r=>r.source!==t.payload.source||t.payload.assistantCode&&r.assistantCode!==t.payload.assistantCode?!0:t.payload.text?r.text!==t.payload.text:!1);let n=e.textSuggestions.length+e.pinnedSuggestions.length;e.selectedSuggestionIndex>n-1&&(e.selectedSuggestionIndex=-1)},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Os.metrics}},extraReducers:e=>{e.addCase(ut,t=>{t.mixedSuggestion=Os.mixedSuggestion,t.textSuggestions=Os.textSuggestions,t.selectedSuggestionIndex=Os.selectedSuggestionIndex,t.metrics=Os.metrics})}}),Ls=e=>{let{text:t,selection:n,suggestionTextStart:r}=e.input;return t.slice(r,n.end)},cN=e=>e.input.mixedSuggestion,uN=e=>e.input.pinnedSuggestions,dN=e=>e.input.textSuggestions,bl=e=>e.input.selectedSuggestionIndex,Ns=un([dN,uN],(e,t)=>[...e,...t]),Ki=un([Ns,cN,bl],(e,t,n)=>n>-1?e[n]:t),Fb=e=>e.input.selection,{commitSuggestion:kn,offeredTextSuggestion:zb,registerCut:Hb,registerKeyDown:Bb,registerKeyUp:Ub,registerPaste:Vb,selectNextTextSuggestion:Wb,selectPreviousTextSuggestion:$b,selectTextSuggestionByIndex:Md,setInput:Od,setMetrics:jb,setPinnedSuggestions:Gi,removePinnedSuggestions:Ds,setSelection:Ld,setTextSuggestions:Ho,resetMetrics:Kb,sendMessage:Fs}=Db.actions,Gb=Db.reducer;function qb(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var fN={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},qi=e=>{var t;return(t=e.info.agentInfo)!=null?t:null},Yb=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},Xb=e=>{var t;return(t=e.info.customData)!=null?t:null},Cl=({info:{visitorInfo:e,agentInfo:t}})=>{var n,r;return{timezone:e!=null&&e.visitorTimeZone&&qb(e.visitorTimeZone)?e.visitorTimeZone:yw,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},pN=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Qb=he("info/setAgentNickname",(n,r)=>_(null,[n,r],function*({agentNickname:e},t){var i;let{deepdeskAPI:o}=t.extra,s=yield o.patchMe({nickname:e});return{agentNickname:(i=s==null?void 0:s.nickname)!=null?i:e}})),El=he("info/setAgentInfo",(e,t)=>_(null,null,function*(){var s,i,a;let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=[];if(e.agentId&&e.skipSync!==!0&&o.push(n.postIdentity({externalId:e.agentId})),e.skipSync!==!0){let l=pN.reduce((c,[u,f])=>!r[f]&&u in e?I(b({},c),{[f]:e[u]}):c,{});Object.keys(l).length>0&&o.push(n.patchMe(l).then(c=>r=c))}return o.length>0&&(yield Promise.all(o)),{agentId:e.agentId,agentName:e.agentName,agentNickname:(s=r.nickname)!=null?s:e.agentNickname,agentEmail:(i=r.email)!=null?i:e.agentEmail,agentDefaultLocale:(a=r.defaultLocale)!=null?a:e.agentDefaultLocale,agentTimeZone:e.agentTimeZone}})),yh=he("info/setAgentSettings",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=b(b({},typeof r.uiConfig=="object"?r.uiConfig:{}),e);return yield n.patchMe({uiConfig:o}),o})),vh=he("info/getAgentSettings",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.getMe()).uiConfig})),Zb=Re({name:"info",initialState:fN,reducers:{setVisitorInfo(e,t){e.visitorInfo=b(b({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload},setPlatformVariables(e,t){e.platformVariables=t.payload},setShowNicknameDialog(e,t){e.showNicknameDialog=t.payload}},extraReducers:e=>{e.addCase(El.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=b(b({},t.agentInfo),n.meta.arg)}).addCase(El.rejected,t=>{t.fetchState="error"}).addCase(El.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=n.payload}).addCase(yh.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(vh.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(ut,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:Jb,setCustomData:eE,setPlatformVariables:tE,setShowNicknameDialog:nE}=Zb.actions,rE=Zb.reducer;function sr(e,t){return t?e==null?(J.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(t)}),e):Object.entries(t).reduce((n,[r,o])=>n.replaceAll(r,o),e):e}var Nd={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},oE=e=>e.search.isOpen,sE=e=>e.search.page,Sh=e=>e.search.list,iE=e=>e.search.aggregates,mN=un([Sh,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),aE=e=>t=>mN(t,e),zs=he("search/getAll",(e,t)=>_(null,null,function*(){var l;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(l=r.conversation.current)==null?void 0:l.profileCode,{platformVariables:s}=r.info;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:o,query:e.query,tags:e.tags,size:e.size,current:e.current,filters:{type:e.type},params:Cl(r)});return{results:i.map(c=>I(b(b({},c),c.title&&s?{title:sr(c.title,s)}:{}),{text:sr(c.text,s!=null?s:{}),source:`search-${c.type.toLowerCase()}`,searchTerm:e.query})),aggregates:a}})),lE=Re({name:"search",initialState:Nd,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Nd.fetchState,e.list=Nd.list}},extraReducers:e=>{e.addCase(zs.pending,t=>{t.fetchState="loading"}).addCase(zs.rejected,(t,n)=>{t.fetchState="error",J.error(n.error)}).addCase(zs.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(ut,()=>Nd)}}),{resetSearch:Dd,setIsOpen:ir,setPage:Yi}=lE.actions,cE=lE.reducer;var xh="SetOutputs",Xi="ShowLoginOverlay",Tl="UserLoggedIn",gN="UserLoggedOut",eo="ApplySuggestion",wh="ApplyImageSuggestion",hN="ShowCommandPalette",Fd="ShowNicknameDialog",zd="ReduxAction",yN="RemovePinnedSuggestion",vN=e=>({[xh]:t=>{var o,s;let n=(o=e.getState().conversation.current)==null?void 0:o.externalId,r=(s=t==null?void 0:t.payload)==null?void 0:s.externalConversationId;r&&r!==n||e.dispatch(I(b({},t),{isBroadcasted:!0}))},[zd]:t=>{t.isBroadcasted||e.dispatch(I(b({},t),{isBroadcasted:!0}))},[yN]:t=>{e.dispatch(Ds(t))},[hN]:t=>{e.dispatch(ir(t.isOpen)),t.page&&e.dispatch(Yi(t.page))},[Fd]:t=>{e.dispatch(nE(t.showNicknameDialog))},[Xi]:t=>{e.dispatch(Pb(t))},[Tl]:()=>{e.dispatch(Jr())},[gN]:()=>{e.dispatch(Jr())},[wh]:t=>{e.dispatch(_d({suggestion:t.suggestion}))},[eo]:t=>{e.dispatch(kn(I(b({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),uE=vN;function Hd(e){return he("analytics/logEvent",(t,n)=>{var s,i,a;let r=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,o=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(t.name,I(b({conversationId:r},o),{data:t.data}))})(e)}function Je(){let e=we();return(t,n)=>_(null,null,function*(){yield e(Hd({name:t,data:n}))})}var Qi=E(X());function Bd(e,t){let n=(0,Qi.useRef)(e);n.current=e;let[r,o]=(0,Qi.useState)(void 0),[s,i]=(0,Qi.useState)(void 0),[a,l]=(0,Qi.useState)("idle"),c=we();return{error:s,state:a,data:r,call:d=>_(null,null,function*(){l("loading"),yield c(n.current(d)).unwrap().then(p=>{o(p),l("done"),t!=null&&t.onSuccess&&(t==null||t.onSuccess(p))}).catch(p=>{i(p),l("error"),t!=null&&t.onError&&(t==null||t.onError(p))})}),reset:()=>{l("idle"),o(void 0),i(void 0)}}}var kl=E(X()),fE=E(A()),dE=kl.default.createContext(null),to=({broadcastEvents:e,children:t})=>{let n=kl.default.useMemo(()=>e,[]);return(0,fE.jsx)(dE.Provider,{value:n,children:t})},dn=()=>{let e=(0,kl.useContext)(dE);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var qd=E(X());var bh=function(e,t){return bh=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])},bh(e,t)};function Rl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");bh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Rn=function(){return Rn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Rn.apply(this,arguments)};function pE(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 Ud(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function Vd(e,t){var n=t&&t.cache?t.cache:TN,r=t&&t.serializer?t.serializer:EN,o=t&&t.strategy?t.strategy:xN;return o(e,{cache:n,serializer:r})}function SN(e){return e==null||typeof e=="number"||typeof e=="boolean"}function mE(e,t,n,r){var o=SN(r)?r:n(r),s=t.get(o);return typeof s=="undefined"&&(s=e.call(this,r),t.set(o,s)),s}function gE(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),s=t.get(o);return typeof s=="undefined"&&(s=e.apply(this,r),t.set(o,s)),s}function Eh(e,t,n,r,o){return n.bind(t,e,r,o)}function xN(e,t){var n=e.length===1?mE:gE;return Eh(e,this,n,t.cache.create(),t.serializer)}function wN(e,t){return Eh(e,this,gE,t.cache.create(),t.serializer)}function bN(e,t){return Eh(e,this,mE,t.cache.create(),t.serializer)}var EN=function(){return JSON.stringify(arguments)},CN=(function(){function e(){this.cache=Object.create(null)}return e.prototype.get=function(t){return this.cache[t]},e.prototype.set=function(t,n){this.cache[t]=n},e})(),TN={create:function(){return new CN}},Wd={variadic:wN,monadic:bN};var $d;(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"})($d||($d={}));var jd=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Vn;(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"})(Vn||(Vn={}));var Kd;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Kd||(Kd={}));function Ch(e){return e.type===Vn.literal}function Th(e){return e.type===Vn.argument}function Pl(e){return e.type===Vn.number}function Al(e){return e.type===Vn.date}function Il(e){return e.type===Vn.time}function _l(e){return e.type===Vn.select}function Ml(e){return e.type===Vn.plural}function hE(e){return e.type===Vn.pound}function Ol(e){return e.type===Vn.tag}function Gd(e){return!!(e&&typeof e=="object"&&e.type===Kd.number)}function Ll(e){return!!(e&&typeof e=="object"&&e.type===Kd.dateTime)}function kh(e){e.forEach(function(t){if(delete t.location,_l(t)||Ml(t))for(var n in t.options)delete t.options[n].location,kh(t.options[n].value);else Pl(t)&&Gd(t.style)||(Al(t)||Il(t))&&Ll(t.style)?delete t.style.location:Ol(t)&&kh(t.children)})}function yE(e,t){t===void 0&&(t={}),t=Rn({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new jd(e,t).parse();if(n.err){var r=SyntaxError($d[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||kh(n.val),n.val}var Hs;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Hs||(Hs={}));var Nl=(function(e){Rl(t,e);function t(n,r,o){var s=e.call(this,n)||this;return s.code=r,s.originalMessage=o,s}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t})(Error);var Rh=(function(e){Rl(t,e);function t(n,r,o,s){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Hs.INVALID_VALUE,s)||this}return t})(Nl);var vE=(function(e){Rl(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Hs.INVALID_VALUE,o)||this}return t})(Nl);var SE=(function(e){Rl(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,'"'),Hs.MISSING_VALUE,r)||this}return t})(Nl);var Ft;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(Ft||(Ft={}));function kN(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==Ft.literal||n.type!==Ft.literal?t.push(n):r.value+=n.value,t},[])}function RN(e){return typeof e=="function"}function Dl(e,t,n,r,o,s,i){if(e.length===1&&Ch(e[0]))return[{type:Ft.literal,value:e[0].value}];for(var a=[],l=0,c=e;l<c.length;l++){var u=c[l];if(Ch(u)){a.push({type:Ft.literal,value:u.value});continue}if(hE(u)){typeof s=="number"&&a.push({type:Ft.literal,value:n.getNumberFormat(t).format(s)});continue}var f=u.value;if(!(o&&f in o))throw new SE(f,i);var d=o[f];if(Th(u)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?Ft.literal:Ft.object,value:d});continue}if(Al(u)){var p=typeof u.style=="string"?r.date[u.style]:Ll(u.style)?u.style.parsedOptions:void 0;a.push({type:Ft.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(Il(u)){var p=typeof u.style=="string"?r.time[u.style]:Ll(u.style)?u.style.parsedOptions:r.time.medium;a.push({type:Ft.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(Pl(u)){var p=typeof u.style=="string"?r.number[u.style]:Gd(u.style)?u.style.parsedOptions:void 0;p&&p.scale&&(d=d*(p.scale||1)),a.push({type:Ft.literal,value:n.getNumberFormat(t,p).format(d)});continue}if(Ol(u)){var h=u.children,y=u.value,S=o[y];if(!RN(S))throw new vE(y,"function",i);var g=Dl(h,t,n,r,o,s),m=S(g.map(function(T){return T.value}));Array.isArray(m)||(m=[m]),a.push.apply(a,m.map(function(T){return{type:typeof T=="string"?Ft.literal:Ft.object,value:T}}))}if(_l(u)){var v=u.options[d]||u.options.other;if(!v)throw new Rh(u.value,d,Object.keys(u.options),i);a.push.apply(a,Dl(v.value,t,n,r,o));continue}if(Ml(u)){var v=u.options["=".concat(d)];if(!v){if(!Intl.PluralRules)throw new Nl(`Intl.PluralRules is not available in this environment.
|
|
12
|
+
`),oe}nd(()=>{nt.current=void 0,te.current=void 0,re.current=Oe});let yt=ce.useMemo(()=>ce.createElement(S,I(b({},Oe),{ref:L})),[L,S,Oe]);return ce.useMemo(()=>h?ce.createElement(V.Provider,{value:j},yt):yt,[V,yt,j])}let C=ce.memo(x);if(C.WrappedComponent=S,C.displayName=x.displayName=m,l){let P=ce.forwardRef(function(D,V){return ce.createElement(C,I(b({},D),{reactReduxForwardedRef:V}))});return P.displayName=m,P.WrappedComponent=S,Bg(P,S)}return Bg(C,S)}}var Mw=qO;function YO(e){let{children:t,context:n,serverState:r,store:o}=e,s=ce.useMemo(()=>{let l=Iw(o);return{store:o,subscription:l,getServerState:r?()=>r:void 0}},[o,r]),i=ce.useMemo(()=>o.getState(),[o]);return nd(()=>{let{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),i!==o.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,i]),ce.createElement((n||Xr).Provider,{value:s},t)}var Ow=YO;function Wg(e=Xr){return function(){return ce.useContext(e)}}var Lw=Wg();function Nw(e=Xr){let t=e===Xr?Lw:Wg(e),n=()=>{let{store:r}=t();return r};return Object.assign(n,{withTypes:()=>n}),n}var XO=Nw();function QO(e=Xr){let t=e===Xr?XO:Nw(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var we=QO(),ZO=(e,t)=>e===t;function JO(e=Xr){let t=e===Xr?Lw:Wg(e),n=(r,o={})=>{let{equalityFn:s=ZO}=typeof o=="function"?{equalityFn:o}:o,i=t(),{store:a,subscription:l,getServerState:c}=i,u=ce.useRef(!0),f=ce.useCallback({[r.name](p){return r(p)}}[r.name],[r]),d=(0,Dw.useSyncExternalStoreWithSelector)(l.addNestedSub,a.getState,c||a.getState,f,s);return ce.useDebugValue(d),d};return Object.assign(n,{withTypes:()=>n}),n}var K=JO();function Ct(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var eL=typeof Symbol=="function"&&Symbol.observable||"@@observable",Fw=eL,$g=()=>Math.random().toString(36).substring(7).split("").join("."),tL={INIT:`@@redux/INIT${$g()}`,REPLACE:`@@redux/REPLACE${$g()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${$g()}`},rd=tL;function od(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function jg(e,t,n){if(typeof e!="function")throw new Error(Ct(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ct(0));if(typeof t=="function"&&typeof n=="undefined"&&(n=t,t=void 0),typeof n!="undefined"){if(typeof n!="function")throw new Error(Ct(1));return n(jg)(e,t)}let r=e,o=t,s=new Map,i=s,a=0,l=!1;function c(){i===s&&(i=new Map,s.forEach((S,g)=>{i.set(g,S)}))}function u(){if(l)throw new Error(Ct(3));return o}function f(S){if(typeof S!="function")throw new Error(Ct(4));if(l)throw new Error(Ct(5));let g=!0;c();let m=a++;return i.set(m,S),function(){if(g){if(l)throw new Error(Ct(6));g=!1,c(),i.delete(m),s=null}}}function d(S){if(!od(S))throw new Error(Ct(7));if(typeof S.type=="undefined")throw new Error(Ct(8));if(typeof S.type!="string")throw new Error(Ct(17));if(l)throw new Error(Ct(9));try{l=!0,o=r(o,S)}finally{l=!1}return(s=i).forEach(m=>{m()}),S}function p(S){if(typeof S!="function")throw new Error(Ct(10));r=S,d({type:rd.REPLACE})}function h(){let S=f;return{subscribe(g){if(typeof g!="object"||g===null)throw new Error(Ct(11));function m(){let x=g;x.next&&x.next(u())}return m(),{unsubscribe:S(m)}},[Fw](){return this}}}return d({type:rd.INIT}),{dispatch:d,subscribe:f,getState:u,replaceReducer:p,[Fw]:h}}function nL(e){Object.keys(e).forEach(t=>{let n=e[t];if(typeof n(void 0,{type:rd.INIT})=="undefined")throw new Error(Ct(12));if(typeof n(void 0,{type:rd.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error(Ct(13))})}function sd(e){let t=Object.keys(e),n={};for(let i=0;i<t.length;i++){let a=t[i];typeof e[a]=="function"&&(n[a]=e[a])}let r=Object.keys(n),o,s;try{nL(n)}catch(i){s=i}return function(a={},l){if(s)throw s;let c=!1,u={};for(let f=0;f<r.length;f++){let d=r[f],p=n[d],h=a[d],y=p(h,l);if(typeof y=="undefined"){let S=l&&l.type;throw new Error(Ct(14))}u[d]=y,c=c||y!==h}return c=c||r.length!==Object.keys(a).length,c?u:a}}function pl(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function zw(...e){return t=>(n,r)=>{let o=t(n,r),s=()=>{throw new Error(Ct(15))},i={getState:o.getState,dispatch:(l,...c)=>s(l,...c)},a=e.map(l=>l(i));return s=pl(...a)(o.dispatch),I(b({},o),{dispatch:s})}}function Hw(e){return od(e)&&"type"in e&&typeof e.type=="string"}var qw=Symbol.for("immer-nothing"),Bw=Symbol.for("immer-draftable"),Dt=Symbol.for("immer-state");function rr(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Cn=Object,Wi=Cn.getPrototypeOf,cd="constructor",gd="prototype",Yg="configurable",ud="enumerable",ad="writable",ml="value",Rr=e=>!!e&&!!e[Dt];function Tn(e){var t;return e?Yw(e)||yd(e)||!!e[Bw]||!!((t=e[cd])!=null&&t[Bw])||vd(e)||Sd(e):!1}var rL=Cn[gd][cd].toString(),Uw=new WeakMap;function Yw(e){if(!e||!rh(e))return!1;let t=Wi(e);if(t===null||t===Cn[gd])return!0;let n=Cn.hasOwnProperty.call(t,cd)&&t[cd];if(n===Object)return!0;if(!Vi(n))return!1;let r=Uw.get(n);return r===void 0&&(r=Function.toString.call(n),Uw.set(n,r)),r===rL}function hd(e,t,n=!0){yl(e)===0?(n?Reflect.ownKeys(e):Cn.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((r,o)=>t(o,r,e))}function yl(e){let t=e[Dt];return t?t.type_:yd(e)?1:vd(e)?2:Sd(e)?3:0}var Kg=(e,t,n=yl(e))=>n===2?e.has(t):Cn[gd].hasOwnProperty.call(e,t),Xg=(e,t,n=yl(e))=>n===2?e.get(t):e[t],dd=(e,t,n,r=yl(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function oL(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var yd=Array.isArray,vd=e=>e instanceof Map,Sd=e=>e instanceof Set,rh=e=>typeof e=="object",Vi=e=>typeof e=="function",Gg=e=>typeof e=="boolean";function sL(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Qr=e=>e.copy_||e.base_;var oh=e=>e.modified_?e.copy_:e.base_;function Qg(e,t){if(vd(e))return new Map(e);if(Sd(e))return new Set(e);if(yd(e))return Array[gd].slice.call(e);let n=Yw(e);if(t===!0||t==="class_only"&&!n){let r=Cn.getOwnPropertyDescriptors(e);delete r[Dt];let o=Reflect.ownKeys(r);for(let s=0;s<o.length;s++){let i=o[s],a=r[i];a[ad]===!1&&(a[ad]=!0,a[Yg]=!0),(a.get||a.set)&&(r[i]={[Yg]:!0,[ad]:!0,[ud]:a[ud],[ml]:e[i]})}return Cn.create(Wi(e),r)}else{let r=Wi(e);if(r!==null&&n)return b({},e);let o=Cn.create(r);return Cn.assign(o,e)}}function sh(e,t=!1){return xd(e)||Rr(e)||!Tn(e)||(yl(e)>1&&Cn.defineProperties(e,{set:id,add:id,clear:id,delete:id}),Cn.freeze(e),t&&hd(e,(n,r)=>{sh(r,!0)},!1)),e}function iL(){rr(2)}var id={[ml]:iL};function xd(e){return e===null||!rh(e)?!0:Cn.isFrozen(e)}var fd="MapSet",Zg="Patches",Vw="ArrayMethods",Xw={};function Ms(e){let t=Xw[e];return t||rr(0,e),t}var Ww=e=>!!Xw[e];var gl,Qw=()=>gl,aL=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ww(fd)?Ms(fd):void 0,arrayMethodsPlugin_:Ww(Vw)?Ms(Vw):void 0});function $w(e,t){t&&(e.patchPlugin_=Ms(Zg),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Jg(e){eh(e),e.drafts_.forEach(lL),e.drafts_=null}function eh(e){e===gl&&(gl=e.parent_)}var jw=e=>gl=aL(gl,e);function lL(e){let t=e[Dt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Kw(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[Dt].modified_&&(Jg(t),rr(4)),Tn(e)&&(e=Gw(t,e));let{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(n[Dt].base_,e,t)}else e=Gw(t,n);return cL(t,e,!0),Jg(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==qw?e:void 0}function Gw(e,t){if(xd(t))return t;let n=t[Dt];if(!n)return pd(t,e.handledSet_,e);if(!wd(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);eb(n,e)}return n.copy_}function cL(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&sh(t,n)}function Zw(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var wd=(e,t)=>e.scope_===t,uL=[];function Jw(e,t,n,r){var a;let o=Qr(e),s=e.type_;if(r!==void 0&&Xg(o,r,s)===t){dd(o,r,n,s);return}if(!e.draftLocations_){let l=e.draftLocations_=new Map;hd(o,(c,u)=>{if(Rr(u)){let f=l.get(u)||[];f.push(c),l.set(u,f)}})}let i=(a=e.draftLocations_.get(t))!=null?a:uL;for(let l of i)dd(o,l,n,s)}function dL(e,t,n){e.callbacks_.push(function(o){var a,l;let s=t;if(!s||!wd(s,o))return;(a=o.mapSetPlugin_)==null||a.fixSetContents(s);let i=oh(s);Jw(e,(l=s.draft_)!=null?l:s,i,n),eb(s,o)})}function eb(e,t){var r,o;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||((o=(r=e.assigned_)==null?void 0:r.size)!=null?o:0)>0)){let{patchPlugin_:s}=t;if(s){let i=s.getPath(e);i&&s.generatePatches_(e,i,t)}Zw(e)}}function fL(e,t,n){let{scope_:r}=e;if(Rr(n)){let o=n[Dt];wd(o,r)&&o.callbacks_.push(function(){ld(e);let i=oh(o);Jw(e,n,i,t)})}else Tn(n)&&e.callbacks_.push(function(){var i;let s=Qr(e);e.type_===3?s.has(n)&&pd(n,r.handledSet_,r):Xg(s,t,e.type_)===n&&r.drafts_.length>1&&((i=e.assigned_.get(t))!=null?i:!1)===!0&&e.copy_&&pd(Xg(e.copy_,t,e.type_),r.handledSet_,r)})}function pd(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Rr(e)||t.has(e)||!Tn(e)||xd(e)||(t.add(e),hd(e,(r,o)=>{if(Rr(o)){let s=o[Dt];if(wd(s,n)){let i=oh(s);dd(e,r,i,e.type_),Zw(s)}}else Tn(o)&&pd(o,t,n)})),e}function pL(e,t){let n=yd(e),r={type_:n?1:0,scope_:t?t.scope_:Qw(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},o=r,s=md;n&&(o=[r],s=hl);let{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,[a,r]}var md={get(e,t){if(t===Dt)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t=="string";if(r&&n!=null&&n.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let o=Qr(e);if(!Kg(o,t,e.type_))return gL(e,o,t);let s=o[t];if(e.finalized_||!Tn(s)||r&&e.operationMethod&&(n!=null&&n.isMutatingArrayMethod(e.operationMethod))&&sL(t))return s;if(s===qg(e.base_,t)||mL(e,t,s)){ld(e);let i=e.type_===1?+t:t,a=nh(e.scope_,s,e,i);return e.copy_[i]=a}return s},has(e,t){return t in Qr(e)},ownKeys(e){return Reflect.ownKeys(Qr(e))},set(e,t,n){let r=tb(Qr(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let o=qg(Qr(e),t),s=o==null?void 0:o[Dt];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(oL(n,o)&&(n!==void 0||Kg(e.base_,t,e.type_)))return!0;ld(e),th(e)}return e.copy_[t]===n&&(n!==void 0||Kg(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),fL(e,t,n)),!0},deleteProperty(e,t){return ld(e),qg(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),th(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Qr(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[ad]:!0,[Yg]:e.type_!==1||t!=="length",[ud]:r[ud],[ml]:n[t]}},defineProperty(){rr(11)},getPrototypeOf(e){return Wi(e.base_)},setPrototypeOf(){rr(12)}},hl={};for(let e in md){let t=md[e];hl[e]=function(){let n=arguments;return n[0]=n[0][0],t.apply(this,n)}}hl.deleteProperty=function(e,t){return hl.set.call(this,e,t,void 0)};hl.set=function(e,t,n){return md.set.call(this,e[0],t,n,e[0])};function qg(e,t){let n=e[Dt];return(n?Qr(n):e)[t]}function mL(e,t,n){var r;return e.type_!==1||!e.allIndicesReassigned_||(r=e.assigned_)!=null&&r.get(t)||!Tn(n)||n[Dt]?!1:e.baseRefs_.has(n)}function gL(e,t,n){var o;let r=tb(t,n);return r?ml in r?r[ml]:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function tb(e,t){if(!(t in e))return;let n=Wi(e);for(;n;){let r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Wi(n)}}function th(e){e.modified_||(e.modified_=!0,e.parent_&&th(e.parent_))}function ld(e){e.copy_||(e.assigned_=new Map,e.copy_=Qg(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var hL=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Vi(t)&&!Vi(n)){let s=n;n=t;let i=this;return function(l=s,...c){return i.produce(l,u=>n.call(this,u,...c))}}Vi(n)||rr(6),r!==void 0&&!Vi(r)&&rr(7);let o;if(Tn(t)){let s=jw(this),i=nh(s,t,void 0),a=!0;try{o=n(i),a=!1}finally{a?Jg(s):eh(s)}return $w(s,r),Kw(o,s)}else if(!t||!rh(t)){if(o=n(t),o===void 0&&(o=t),o===qw&&(o=void 0),this.autoFreeze_&&sh(o,!0),r){let s=[],i=[];Ms(Zg).generateReplacementPatches_(t,o,{patches_:s,inversePatches_:i}),r(s,i)}return o}else rr(1,t)},this.produceWithPatches=(t,n)=>{if(Vi(t))return(i,...a)=>this.produceWithPatches(i,l=>t(l,...a));let r,o;return[this.produce(t,n,(i,a)=>{r=i,o=a}),r,o]},Gg(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Gg(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Gg(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Tn(e)||rr(8),Rr(e)&&(e=nb(e));let t=jw(this),n=nh(t,e,void 0);return n[Dt].isManual_=!0,eh(t),n}finishDraft(e,t){let n=e&&e[Dt];(!n||!n.isManual_)&&rr(9);let{scope_:r}=n;return $w(r,t),Kw(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));let r=Ms(Zg).applyPatches_;return Rr(e)?r(e,t):this.produce(e,o=>r(o,t))}};function nh(e,t,n,r){var a,l;let[o,s]=vd(t)?Ms(fd).proxyMap_(t,n):Sd(t)?Ms(fd).proxySet_(t,n):pL(t,n);return((a=n==null?void 0:n.scope_)!=null?a:Qw()).drafts_.push(o),s.callbacks_=(l=n==null?void 0:n.callbacks_)!=null?l:[],s.key_=r,n&&r!==void 0?dL(n,s,r):s.callbacks_.push(function(u){var d;(d=u.mapSetPlugin_)==null||d.fixSetContents(s);let{patchPlugin_:f}=u;s.modified_&&f&&f.generatePatches_(s,[],u)}),o}function nb(e){return Rr(e)||rr(10,e),rb(e)}function rb(e){if(!Tn(e)||xd(e))return e;let t=e[Dt],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Qg(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Qg(e,!0);return hd(n,(o,s)=>{dd(n,o,rb(s))},r),t&&(t.finalized_=!1),n}var yL=new hL,ih=yL.produce;function vL(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function SL(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){let n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var ob=e=>Array.isArray(e)?e:[e];function xL(e){let t=Array.isArray(e[0])?e[0]:e;return SL(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function wL(e,t){let n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var bL=class{constructor(e){this.value=e}deref(){return this.value}},EL=()=>typeof WeakRef=="undefined"?bL:WeakRef,ib=EL(),CL=0,sb=1;function bd(){return{s:CL,v:void 0,o:null,p:null}}function TL(e){return e instanceof ib?e.deref():e}function ab(e,t={}){let n=bd(),{resultEqualityCheck:r}=t,o,s=0;function i(){let a=n,{length:l}=arguments;for(let f=0,d=l;f<d;f++){let p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let h=a.o;h===null&&(a.o=h=new WeakMap);let y=h.get(p);y===void 0?(a=bd(),h.set(p,a)):a=y}else{let h=a.p;h===null&&(a.p=h=new Map);let y=h.get(p);y===void 0?(a=bd(),h.set(p,a)):a=y}}let c=a,u;if(a.s===sb)u=a.v;else if(u=e.apply(null,arguments),s++,r){let f=TL(o);f!=null&&r(f,u)&&(u=f,s!==0&&s--),o=typeof u=="object"&&u!==null||typeof u=="function"?new ib(u):u}return c.s=sb,c.v=u,u}return i.clearCache=()=>{n=bd(),i.resetResultsCount()},i.resultsCount=()=>s,i.resetResultsCount=()=>{s=0},i}function kL(e,...t){let n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...o)=>{let s=0,i=0,a,l={},c=o.pop();typeof c=="object"&&(l=c,c=o.pop()),vL(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);let u=b(b({},n),l),{memoize:f,memoizeOptions:d=[],argsMemoize:p=ab,argsMemoizeOptions:h=[]}=u,y=ob(d),S=ob(h),g=xL(o),m=f(function(){return s++,c.apply(null,arguments)},...y),v=!0,x=p(function(){i++;let C=wL(g,arguments);return a=m.apply(null,C),a},...S);return Object.assign(x,{resultFunc:c,memoizedResultFunc:m,dependencies:g,dependencyRecomputations:()=>i,resetDependencyRecomputations:()=>{i=0},lastResult:()=>a,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var un=kL(ab);function lb(e){return({dispatch:n,getState:r})=>o=>s=>typeof s=="function"?s(n,r,e):o(s)}var cb=lb(),ub=lb;var RL=typeof window!="undefined"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pl:pl.apply(null,arguments)},q8=typeof window!="undefined"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}},PL=e=>e&&typeof e.match=="function";function Tt(e,t){function n(...r){if(t){let o=t(...r);if(!o)throw new Error(Zr(0));return b(b({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>Hw(r)&&r.type===e,n}var gb=class vl extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,vl.prototype)}static get[Symbol.species](){return vl}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new vl(...t[0].concat(this)):new vl(...t.concat(this))}};function db(e){return Tn(e)?ih(e,()=>{}):e}function Ed(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function AL(e){return typeof e=="boolean"}var IL=()=>function(t){let{thunk:n=!0,immutableCheck:r=!0,serializableCheck:o=!0,actionCreatorCheck:s=!0}=t!=null?t:{},i=new gb;return n&&(AL(n)?i.push(cb):i.push(ub(n.extraArgument))),i},_L="RTK_autoBatch";var fb=e=>t=>{setTimeout(t,e)},ML=(e,t)=>n=>{let r=!1,o=()=>{r||(r=!0,cancelAnimationFrame(s),clearTimeout(i),n())},s=e(o),i=setTimeout(o,t)},OL=(e={type:"raf"})=>t=>(...n)=>{let r=t(...n),o=!0,s=!1,i=!1,a=new Set,l=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window!="undefined"&&window.requestAnimationFrame?ML(window.requestAnimationFrame,100):fb(10):e.type==="callback"?e.queueNotification:fb(e.timeout),c=()=>{i=!1,s&&(s=!1,a.forEach(u=>u()))};return Object.assign({},r,{subscribe(u){let f=()=>o&&u(),d=r.subscribe(f);return a.add(u),()=>{d(),a.delete(u)}},dispatch(u){var f;try{return o=!((f=u==null?void 0:u.meta)!=null&&f[_L]),s=!o,s&&(i||(i=!0,l(c))),r.dispatch(u)}finally{o=!0}}})},LL=e=>function(n){let{autoBatch:r=!0}=n!=null?n:{},o=new gb(e);return r&&o.push(OL(typeof r=="object"?r:void 0)),o};function hb(e){let t=IL(),{reducer:n=void 0,middleware:r,devTools:o=!0,duplicateMiddlewareCheck:s=!0,preloadedState:i=void 0,enhancers:a=void 0}=e||{},l;if(typeof n=="function")l=n;else if(od(n))l=sd(n);else throw new Error(Zr(1));let c;typeof r=="function"?c=r(t):c=t();let u=pl;o&&(u=RL(b({trace:!1},typeof o=="object"&&o)));let f=zw(...c),d=LL(f),p=typeof a=="function"?a(d):d(),h=u(...p);return jg(l,i,h)}function yb(e){let t={},n=[],r,o={addCase(s,i){let a=typeof s=="string"?s:s.type;if(!a)throw new Error(Zr(28));if(a in t)throw new Error(Zr(29));return t[a]=i,o},addAsyncThunk(s,i){return i.pending&&(t[s.pending.type]=i.pending),i.rejected&&(t[s.rejected.type]=i.rejected),i.fulfilled&&(t[s.fulfilled.type]=i.fulfilled),i.settled&&n.push({matcher:s.settled,reducer:i.settled}),o},addMatcher(s,i){return n.push({matcher:s,reducer:i}),o},addDefaultCase(s){return r=s,o}};return e(o),[t,n,r]}function NL(e){return typeof e=="function"}function DL(e,t){let[n,r,o]=yb(t),s;if(NL(e))s=()=>db(e());else{let a=db(e);s=()=>a}function i(a=s(),l){let c=[n[l.type],...r.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[o]),c.reduce((u,f)=>{if(f)if(Rr(u)){let p=f(u,l);return p===void 0?u:p}else{if(Tn(u))return ih(u,d=>f(d,l));{let d=f(u,l);if(d===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return d}}return u},a)}return i.getInitialState=s,i}var FL=(e,t)=>PL(e)?e.match(t):e(t);function zL(...e){return t=>e.some(n=>FL(n,t))}var HL="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",BL=(e=21)=>{let t="",n=e;for(;n--;)t+=HL[Math.random()*64|0];return t},UL=["name","message","stack","code"],ah=class{constructor(e,t){xe(this,"payload");xe(this,"meta");xe(this,"_type");this.payload=e,this.meta=t}},pb=class{constructor(e,t){xe(this,"payload");xe(this,"meta");xe(this,"_type");this.payload=e,this.meta=t}},VL=e=>{if(typeof e=="object"&&e!==null){let t={};for(let n of UL)typeof e[n]=="string"&&(t[n]=e[n]);return t}return{message:String(e)}},mb="External signal was aborted",he=(()=>{function e(t,n,r){let o=Tt(t+"/fulfilled",(l,c,u,f)=>({payload:l,meta:I(b({},f||{}),{arg:u,requestId:c,requestStatus:"fulfilled"})})),s=Tt(t+"/pending",(l,c,u)=>({payload:void 0,meta:I(b({},u||{}),{arg:c,requestId:l,requestStatus:"pending"})})),i=Tt(t+"/rejected",(l,c,u,f,d)=>({payload:f,error:(r&&r.serializeError||VL)(l||"Rejected"),meta:I(b({},d||{}),{arg:u,requestId:c,rejectedWithValue:!!f,requestStatus:"rejected",aborted:(l==null?void 0:l.name)==="AbortError",condition:(l==null?void 0:l.name)==="ConditionError"})}));function a(l,{signal:c}={}){return(u,f,d)=>{let p=r!=null&&r.idGenerator?r.idGenerator(l):BL(),h=new AbortController,y,S;function g(v){S=v,h.abort()}c&&(c.aborted?g(mb):c.addEventListener("abort",()=>g(mb),{once:!0}));let m=(function(){return _(this,null,function*(){var T,C;let v;try{let k=(T=r==null?void 0:r.condition)==null?void 0:T.call(r,l,{getState:f,extra:d});if($L(k)&&(k=yield k),k===!1||h.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let P=new Promise((L,D)=>{y=()=>{D({name:"AbortError",message:S||"Aborted"})},h.signal.addEventListener("abort",y,{once:!0})});u(s(p,l,(C=r==null?void 0:r.getPendingMeta)==null?void 0:C.call(r,{requestId:p,arg:l},{getState:f,extra:d}))),v=yield Promise.race([P,Promise.resolve(n(l,{dispatch:u,getState:f,extra:d,requestId:p,signal:h.signal,abort:g,rejectWithValue:((L,D)=>new ah(L,D)),fulfillWithValue:((L,D)=>new pb(L,D))})).then(L=>{if(L instanceof ah)throw L;return L instanceof pb?o(L.payload,p,l,L.meta):o(L,p,l)})])}catch(k){v=k instanceof ah?i(null,p,l,k.payload,k.meta):i(k,p,l)}finally{y&&h.signal.removeEventListener("abort",y)}return r&&!r.dispatchConditionRejection&&i.match(v)&&v.meta.condition||u(v),v})})();return Object.assign(m,{abort:g,requestId:p,arg:l,unwrap(){return m.then(WL)}})}}return Object.assign(a,{pending:s,rejected:i,fulfilled:o,settled:zL(i,o),typePrefix:t})}return e.withTypes=()=>e,e})();function WL(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function $L(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var vb=Symbol.for("rtk-slice-createasyncthunk"),X8={[vb]:he};function jL(e,t){return`${e}/${t}`}function KL({creators:e}={}){var n;let t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[vb];return function(o){let{name:s,reducerPath:i=s}=o;if(!s)throw new Error(Zr(11));let a=(typeof o.reducers=="function"?o.reducers(qL()):o.reducers)||{},l=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(x,T){let C=typeof x=="string"?x:x.type;if(!C)throw new Error(Zr(12));if(C in c.sliceCaseReducersByType)throw new Error(Zr(13));return c.sliceCaseReducersByType[C]=T,u},addMatcher(x,T){return c.sliceMatchers.push({matcher:x,reducer:T}),u},exposeAction(x,T){return c.actionCreators[x]=T,u},exposeCaseReducer(x,T){return c.sliceCaseReducersByName[x]=T,u}};l.forEach(x=>{let T=a[x],C={reducerName:x,type:jL(s,x),createNotation:typeof o.reducers=="function"};XL(T)?ZL(C,T,u,t):YL(C,T,u)});function f(){let[x={},T=[],C=void 0]=typeof o.extraReducers=="function"?yb(o.extraReducers):[o.extraReducers],k=b(b({},x),c.sliceCaseReducersByType);return DL(o.initialState,P=>{for(let L in k)P.addCase(L,k[L]);for(let L of c.sliceMatchers)P.addMatcher(L.matcher,L.reducer);for(let L of T)P.addMatcher(L.matcher,L.reducer);C&&P.addDefaultCase(C)})}let d=x=>x,p=new Map,h=new WeakMap,y;function S(x,T){return y||(y=f()),y(x,T)}function g(){return y||(y=f()),y.getInitialState()}function m(x,T=!1){function C(P){let L=P[x];return typeof L=="undefined"&&T&&(L=Ed(h,C,g)),L}function k(P=d){let L=Ed(p,T,()=>new WeakMap);return Ed(L,P,()=>{var V;let D={};for(let[ne,Y]of Object.entries((V=o.selectors)!=null?V:{}))D[ne]=GL(Y,P,()=>Ed(h,P,g),T);return D})}return{reducerPath:x,getSelectors:k,get selectors(){return k(C)},selectSlice:C}}let v=I(b({name:s,reducer:S,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:g},m(i)),{injectInto(x,k={}){var P=k,{reducerPath:T}=P,C=ie(P,["reducerPath"]);let L=T!=null?T:i;return x.inject({reducerPath:L,reducer:S},C),b(b({},v),m(L,!0))}});return v}}function GL(e,t,n,r){function o(s,...i){let a=t(s);return typeof a=="undefined"&&r&&(a=n()),e(a,...i)}return o.unwrapped=e,o}var Re=KL();function qL(){function e(t,n){return b({_reducerDefinitionType:"asyncThunk",payloadCreator:t},n)}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function YL({type:e,reducerName:t,createNotation:n},r,o){let s,i;if("reducer"in r){if(n&&!QL(r))throw new Error(Zr(17));s=r.reducer,i=r.prepare}else s=r;o.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,i?Tt(e,i):Tt(e))}function XL(e){return e._reducerDefinitionType==="asyncThunk"}function QL(e){return e._reducerDefinitionType==="reducerWithPrepare"}function ZL({type:e,reducerName:t},n,r,o){if(!o)throw new Error(Zr(18));let{payloadCreator:s,fulfilled:i,pending:a,rejected:l,settled:c,options:u}=n,f=o(e,s,u);r.exposeAction(t,f),i&&r.addCase(f.fulfilled,i),a&&r.addCase(f.pending,a),l&&r.addCase(f.rejected,l),c&&r.addMatcher(f.settled,c),r.exposeCaseReducer(t,{fulfilled:i||Cd,pending:a||Cd,rejected:l||Cd,settled:c||Cd})}function Cd(){}var Sb="listener",xb="completed",wb="cancelled",Q8=`task-${wb}`,Z8=`task-${xb}`,J8=`${Sb}-${wb}`,eH=`${Sb}-${xb}`;var{assign:bb}=Object;var lh="listenerMiddleware";var JL=bb(Tt(`${lh}/add`),{withTypes:()=>JL}),tH=Tt(`${lh}/removeAll`),eN=bb(Tt(`${lh}/remove`),{withTypes:()=>eN});function Zr(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Sl=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(Sl||{});var tN={isLoggedIn:null,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1,loginError:null},kt=e=>e.auth.isLoggedIn;var Eb=e=>e.auth.verifyFetchState,Cb=e=>e.auth.showLoginOverlay,Tb=e=>e.auth.loginError,Jr=he("auth/validate",(e,t)=>_(null,null,function*(){return t.extra.deepdeskAPI.isLoggedIn()})),kb=he("auth/requestLogin",(n,r)=>_(null,[n,r],function*({email:e},t){let{deepdeskAPI:o}=t.extra;return o.requestLoginByEmail(e)})),ch=he("auth/loginWithPassword",(r,o)=>_(null,[r,o],function*({username:e,password:t},n){let{deepdeskAPI:s}=n.extra;return s.loginWithPassword(e,t)})),Td=he("auth/logout",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra;yield n.logout()})),xl=he("auth/verifyLoginToken",(n,r)=>_(null,[n,r],function*({token:e},t){let{deepdeskAPI:o}=t.extra;return o.verifyLoginToken(e)})),Rb=Re({name:"auth",initialState:tN,reducers:{setIsLoggedIn(e,t){e.isLoggedIn=t.payload},setShowLoginOverlay(e,t){e.showLoginOverlay=t.payload},setLoginError(e,t){e.loginError=t.payload},clearLoginError(e){e.loginError=null}},extraReducers:e=>{e.addCase(Jr.pending,t=>{t.loginFetchState="loading"}),e.addCase(Jr.fulfilled,(t,{payload:n})=>{t.isLoggedIn=n,t.loginFetchState="done"}),e.addCase(Jr.rejected,t=>{t.loginFetchState="error",t.isLoggedIn=!1}),e.addCase(ch.pending,t=>{t.loginFetchState="loading",t.loginError=null}),e.addCase(ch.fulfilled,t=>{t.isLoggedIn=!0,t.loginFetchState="done",t.loginError=null,t.showLoginOverlay=!1}),e.addCase(ch.rejected,(t,n)=>{t.loginFetchState="error",t.isLoggedIn=!1,t.loginError=n.error.message==="Bad Request"?"Invalid credentials":"Login failed"}),e.addCase(Td.fulfilled,t=>{t.isLoggedIn=!1,t.loginFetchState="idle",t.loginError=null}),e.addCase(Td.rejected,t=>{t.isLoggedIn=!1,t.loginFetchState="error"}),e.addCase(xl.pending,t=>{t.verifyFetchState="loading"}),e.addCase(xl.rejected,t=>{t.verifyFetchState="error"}),e.addCase(xl.fulfilled,(t,n)=>{n.payload.isLoggedIn?t.verifyFetchState="done":t.verifyFetchState="error"})}}),{setIsLoggedIn:$i,setShowLoginOverlay:Pb,setLoginError:uh,clearLoginError:kd}=Rb.actions,Ab=Rb.reducer;var wl=class{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);let s=this.castInput(t,r),i=this.castInput(n,r),a=this.removeEmpty(this.tokenize(s,r)),l=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(a,l,r,o)}diffWithOptionsObj(t,n,r,o){var s;let i=m=>{if(m=this.postProcess(m,r),o){setTimeout(function(){o(m)},0);return}else return m},a=n.length,l=t.length,c=1,u=a+l;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));let f=(s=r.timeout)!==null&&s!==void 0?s:1/0,d=Date.now()+f,p=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(p[0],n,t,0,r);if(p[0].oldPos+1>=l&&h+1>=a)return i(this.buildValues(p[0].lastComponent,n,t));let y=-1/0,S=1/0,g=()=>{for(let m=Math.max(y,-c);m<=Math.min(S,c);m+=2){let v,x=p[m-1],T=p[m+1];x&&(p[m-1]=void 0);let C=!1;if(T){let P=T.oldPos-m;C=T&&0<=P&&P<a}let k=x&&x.oldPos+1<l;if(!C&&!k){p[m]=void 0;continue}if(!k||C&&x.oldPos<T.oldPos?v=this.addToPath(T,!0,!1,0,r):v=this.addToPath(x,!1,!0,1,r),h=this.extractCommon(v,n,t,m,r),v.oldPos+1>=l&&h+1>=a)return i(this.buildValues(v.lastComponent,n,t))||!0;p[m]=v,v.oldPos+1>=l&&(S=Math.min(S,m-1)),h+1>=a&&(y=Math.max(y,m+1))}c++};if(o)(function m(){setTimeout(function(){if(c>u||Date.now()>d)return o(void 0);g()||m()},0)})();else for(;c<=u&&Date.now()<=d;){let m=g();if(m)return m}}addToPath(t,n,r,o,s){let i=t.lastComponent;return i&&!s.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}}extractCommon(t,n,r,o,s){let i=n.length,a=r.length,l=t.oldPos,c=l-o,u=0;for(;c+1<i&&l+1<a&&this.equals(r[l+1],n[c+1],s);)c++,l++,u++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!s.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=l,c}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){let n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){let o=[],s;for(;t;)o.push(t),s=t.previousComponent,delete t.previousComponent,t=s;o.reverse();let i=o.length,a=0,l=0,c=0;for(;a<i;a++){let u=o[a];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let f=n.slice(l,l+u.count);f=f.map(function(d,p){let h=r[c+p];return h.length>d.length?h:d}),u.value=this.join(f)}else u.value=this.join(n.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return o}};var dh=class extends wl{},Ib=new dh;function fh(e,t,n){return Ib.diff(e,t,n)}function _b(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function zo(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((s,i)=>zo(s,t[i],n-1)):_b(e)&&_b(t)?Object.keys(e).length!==Object.keys(t).length?!1:Object.keys(e).every(i=>zo(e[i],t[i],n-1)):!1}function nN(e){return Math.max(...e.map(t=>t.length))}function rN(e,t){let n=e.reduce((r,o)=>{if(o){let s=r[o]?r[o]+1:1;return I(b({},r),{[o]:s})}return r},{});return Object.keys(n).reduce((r,o)=>(n[o]<t&&r.push(o),r),[])}function Mb(e,t){let r=[...e.map(({text:o})=>o.split(/\b(\w+)\b/))];for(let o=0;o<nN(r);o++){let s=rN(r.map(a=>a[o]),t),i=r.filter(a=>!s.includes(a[o]));if(i.length>=t)r=i;else return{text:r[0].slice(0,o).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var oN=2;function Ob(e,t=""){if(e.length===0)return;if(e.length===1)return e[0];let n=Mb(e,oN);return n&&n.text!==t?n:e[0]}var sN={info(...e){console.info("[Deepdesk]",...e)},warn(...e){console.warn("[Deepdesk]",...e)},error(...e){console.error("[Deepdesk]",...e)}},J=sN;var Lb={current:null,isSupported:null},ut=Tt("resetConversation"),Rd=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.externalId)||null},Pr=e=>{let{current:t}=e.conversation;return(t==null?void 0:t.id)||null},ji=e=>e.conversation.isSupported,ph=he("conversation/isSupported",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.isConversationSupported(e.externalId,e.options)}),Pd=he("conversation/create",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.createConversation(e)}),Ad=he("conversation/byExternalId",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.getConversationByExternalId(e.externalId,e.options)}),Id=he("conversation/update",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=Pr(t.getState());if(!r)throw new Error("No current conversation to update");return n.updateConversation(r,e)}),mh=he("conversation/upsert",(e,t)=>{let{deepdeskAPI:n}=t.extra;return n.upsertConversation(e)}),gh=he("conversation/postMessages",(e,t)=>{let{deepdeskAPI:n}=t.extra,r=Pr(t.getState());if(!r){J.warn("No current conversation to update messages");return}return n.postMessages(r,e.map(o=>b({},o)))}),iN=[Pd.rejected,Ad.rejected,Id.rejected,gh.rejected].map(e=>e==null?void 0:e.toString());function aN(e){return iN.includes(e.type)}var lN=Re({name:"conversation",initialState:Lb,reducers:{},extraReducers:e=>{e.addCase(ph.fulfilled,(t,n)=>{t.isSupported=n.payload}).addCase(Pd.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Ad.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(mh.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(Id.fulfilled,(t,n)=>{var r;t.current=n.payload,t.isSupported=!!((r=n.payload)!=null&&r.profileCode)}).addCase(ut,()=>Lb).addMatcher(aN,(t,n)=>{var r;throw J.info("Conversation action rejected",n.type,((r=n.error)==null?void 0:r.message)||"No message"),new Error(n.error.message)})}}),Nb=lN.reducer;var Os={text:"",html:null,suggestionTextStart:0,selection:{start:0,end:0},beforeInputChange:null,mixedSuggestion:null,textSuggestions:[],pinnedSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,externalTimeTotalSeconds:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function hh(e){let{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:s}=e;return{key:t,shiftKey:n,ctrlKey:r,metaKey:o,altKey:s}}var _d=Tt("input/applyImageSuggestion"),Db=Re({name:"input",initialState:Os,reducers:{setInput(e,t){var i,a;let{beforeInputChange:n}=e,{text:r,html:o,suggestionTextStart:s}=t.payload;if(e.text=r,e.html=o!=null?o:null,e.suggestionTextStart=r===""?0:Math.max(0,s!=null?s:0),r==="")e.metrics=Os.metrics,e.textSuggestions=[],e.mixedSuggestion=null;else if(n!==null&&e.text!==n.text){let{key:l,shiftKey:c,ctrlKey:u,metaKey:f,altKey:d}=n.keyDown;switch(l){case"Enter":c&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:p}=e,h=fh(n.text,p);n.text.length-p.length>1&&e.metrics.deletions.push(...h.filter(y=>y.removed).map(y=>y.value)),e.metrics.numCharsDeleted+=n.text.length-p.length;break}case"Shift":case"Meta":case"Tab":break;case"C":case"V":case"X":case"c":case"v":case"x":if(u||f)break;default:if(!u&&!f&&!d){e.metrics.numCharsTyped+=1;let p=((i=n.selection)==null?void 0:i.start)!==void 0&&((a=n.selection)==null?void 0:a.end)!==void 0?n.text.substring(n.selection.start,n.selection.end):null;p&&p.length>0&&(e.metrics.numCharsDeleted+=p.length,e.metrics.deletions.push(p))}}e.metrics.agentStartedTypingTimestamp||(e.metrics.agentStartedTypingTimestamp=Date.now())}e.beforeInputChange=null},sendMessage(e,t){e.pinnedSuggestions=e.pinnedSuggestions.filter(n=>!e.metrics.textSuggestions.some(r=>r.text===n.text&&r.source===n.source))},setSelection(e,t){t.payload!==null&&(zo(e.selection,t.payload)||(e.selection=t.payload))},commitSuggestion(e,t){let n=t.payload,{text:r,suggestion:{source:o,abVariant:s,abTestName:i,trainingJobs:a,sourceText:l,searchTerm:c,assistantCode:u,text:f},eventMetrics:{inputType:d},replace:p}=n,h=o==="search"||o==="personal-collection-search",y=r.slice(e.text.substring(0,e.selection.start).length);(h||p==="selection")&&(y=r),n.suggestion.source==="search-overlay"&&(y=f),e.metrics.textSuggestions.push({text:y,source:o,assistantCode:u,abVariant:s,abTestName:i,inputType:d,sourceText:l,trainingJobs:a||[],searchTerm:h?e.text:c}),e.textSuggestions=[],e.selectedSuggestionIndex=-1},offeredTextSuggestion(e,t){let{text:n,suggestion:{source:r}}=t.payload;e.metrics.offeredTextSuggestions.find(s=>s.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=I(b({},e.metrics),{numCharsCut:n.numCharsCut+r.length,cuts:[...n.cuts,r]})},registerPaste(e,t){let{metrics:n}=e,{text:r,selectionText:o}=t.payload,s=n.numCharsDeleted+(o!=null&&o.length?o.length:0),i=o!=null&&o.length?[...n.deletions,o]:n.deletions;e.metrics=I(b({},e.metrics),{numCharsDeleted:s,deletions:i,numCharsPasted:n.numCharsPasted+r.length,numPaste:n.numPaste+1,pastes:[...n.pastes,r]})},selectNextTextSuggestion(e){let t=e.textSuggestions.length+e.pinnedSuggestions.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=Ls({input:e}),r=Ob(t.payload,n);e.mixedSuggestion=r!=null&&r.text.includes(n)?r:null},setPinnedSuggestions(e,t){e.pinnedSuggestions=t.payload},removePinnedSuggestions(e,t){e.pinnedSuggestions=e.pinnedSuggestions.filter(r=>r.source!==t.payload.source||t.payload.assistantCode&&r.assistantCode!==t.payload.assistantCode?!0:t.payload.text?r.text!==t.payload.text:!1);let n=e.textSuggestions.length+e.pinnedSuggestions.length;e.selectedSuggestionIndex>n-1&&(e.selectedSuggestionIndex=-1)},setMetrics(e,{payload:t}){e.metrics=t},resetMetrics(e){e.metrics=Os.metrics}},extraReducers:e=>{e.addCase(ut,t=>{t.mixedSuggestion=Os.mixedSuggestion,t.textSuggestions=Os.textSuggestions,t.selectedSuggestionIndex=Os.selectedSuggestionIndex,t.metrics=Os.metrics})}}),Ls=e=>{let{text:t,selection:n,suggestionTextStart:r}=e.input;return t.slice(r,n.end)},cN=e=>e.input.mixedSuggestion,uN=e=>e.input.pinnedSuggestions,dN=e=>e.input.textSuggestions,bl=e=>e.input.selectedSuggestionIndex,Ns=un([dN,uN],(e,t)=>[...e,...t]),Ki=un([Ns,cN,bl],(e,t,n)=>n>-1?e[n]:t),Fb=e=>e.input.selection,{commitSuggestion:kn,offeredTextSuggestion:zb,registerCut:Hb,registerKeyDown:Bb,registerKeyUp:Ub,registerPaste:Vb,selectNextTextSuggestion:Wb,selectPreviousTextSuggestion:$b,selectTextSuggestionByIndex:Md,setInput:Od,setMetrics:jb,setPinnedSuggestions:Gi,removePinnedSuggestions:Ds,setSelection:Ld,setTextSuggestions:Ho,resetMetrics:Kb,sendMessage:Fs}=Db.actions,Gb=Db.reducer;function qb(e){try{return Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch(t){return!1}}var fN={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,customData:void 0,platformVariables:void 0,fetchState:"idle",showNicknameDialog:!1},qi=e=>{var t;return(t=e.info.agentInfo)!=null?t:null},Yb=e=>{var t;return(t=e.info.visitorInfo)!=null?t:null},Xb=e=>{var t;return(t=e.info.customData)!=null?t:null},Cl=({info:{visitorInfo:e,agentInfo:t}})=>{var n,r;return{timezone:e!=null&&e.visitorTimeZone&&qb(e.visitorTimeZone)?e.visitorTimeZone:yw,agentName:(n=t==null?void 0:t.agentNickname)!=null?n:"",visitorName:(r=e==null?void 0:e.visitorName)!=null?r:""}},pN=[["agentNickname","nickname"],["agentDefaultLocale","defaultLocale"],["agentEmail","email"]],Qb=he("info/setAgentNickname",(n,r)=>_(null,[n,r],function*({agentNickname:e},t){var i;let{deepdeskAPI:o}=t.extra,s=yield o.patchMe({nickname:e});return{agentNickname:(i=s==null?void 0:s.nickname)!=null?i:e}})),El=he("info/setAgentInfo",(e,t)=>_(null,null,function*(){var s,i,a;let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=[];if(e.agentId&&e.skipSync!==!0&&o.push(n.postIdentity({externalId:e.agentId})),e.skipSync!==!0){let l=pN.reduce((c,[u,f])=>!r[f]&&u in e?I(b({},c),{[f]:e[u]}):c,{});Object.keys(l).length>0&&o.push(n.patchMe(l).then(c=>r=c))}return o.length>0&&(yield Promise.all(o)),{agentId:e.agentId,agentName:e.agentName,agentNickname:(s=r.nickname)!=null?s:e.agentNickname,agentEmail:(i=r.email)!=null?i:e.agentEmail,agentDefaultLocale:(a=r.defaultLocale)!=null?a:e.agentDefaultLocale,agentTimeZone:e.agentTimeZone}})),yh=he("info/setAgentSettings",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra,r=yield n.getMe(),o=b(b({},typeof r.uiConfig=="object"?r.uiConfig:{}),e);return yield n.patchMe({uiConfig:o}),o})),vh=he("info/getAgentSettings",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra;return(yield n.getMe()).uiConfig})),Zb=Re({name:"info",initialState:fN,reducers:{setVisitorInfo(e,t){e.visitorInfo=b(b({},e.visitorInfo),t.payload)},setCustomData(e,t){e.customData=t.payload},setPlatformVariables(e,t){e.platformVariables=t.payload},setShowNicknameDialog(e,t){e.showNicknameDialog=t.payload}},extraReducers:e=>{e.addCase(El.pending,(t,n)=>{t.fetchState="loading",t.agentInfo=b(b({},t.agentInfo),n.meta.arg)}).addCase(El.rejected,t=>{t.fetchState="error"}).addCase(El.fulfilled,(t,n)=>{t.fetchState="done",t.agentInfo=n.payload}).addCase(yh.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(vh.fulfilled,(t,n)=>{t.agentSettings=n.payload}).addCase(ut,t=>{t.visitorInfo=void 0})}}),{setVisitorInfo:Jb,setCustomData:eE,setPlatformVariables:tE,setShowNicknameDialog:nE}=Zb.actions,rE=Zb.reducer;function sr(e,t){return t?e==null?(J.warn("replaceVars called with non-string text; upstream contract violation",{keys:Object.keys(t)}),e):Object.entries(t).reduce((n,[r,o])=>n.replaceAll(r,o),e):e}var Nd={list:[],fetchState:"idle",isOpen:!1,page:"search",aggregates:{}},oE=e=>e.search.isOpen,sE=e=>e.search.page,Sh=e=>e.search.list,iE=e=>e.search.aggregates,mN=un([Sh,(e,t)=>t],(e,t)=>e.filter(n=>n.type===t)),aE=e=>t=>mN(t,e),zs=he("search/getAll",(e,t)=>_(null,null,function*(){var l;let{deepdeskAPI:n}=t.extra,r=t.getState(),o=(l=r.conversation.current)==null?void 0:l.profileCode,{platformVariables:s}=r.info;if(!o)throw new Error("Profile should be provided in order to be able to search");let{results:i,aggregates:a}=yield n.search({profile:o,query:e.query,tags:e.tags,size:e.size,current:e.current,filters:{type:e.type},params:Cl(r)});return{results:i.map(c=>I(b(b({},c),c.title&&s?{title:sr(c.title,s)}:{}),{text:sr(c.text,s!=null?s:{}),source:`search-${c.type.toLowerCase()}`,searchTerm:e.query})),aggregates:a}})),lE=Re({name:"search",initialState:Nd,reducers:{setIsOpen(e,t){e.isOpen=t.payload},setPage(e,t){e.page=t.payload},resetSearch(e){e.fetchState=Nd.fetchState,e.list=Nd.list}},extraReducers:e=>{e.addCase(zs.pending,t=>{t.fetchState="loading"}).addCase(zs.rejected,(t,n)=>{t.fetchState="error",J.error(n.error)}).addCase(zs.fulfilled,(t,n)=>{t.fetchState="done",t.list=n.payload.results,t.aggregates=n.payload.aggregates||{}}).addCase(ut,()=>Nd)}}),{resetSearch:Dd,setIsOpen:ir,setPage:Yi}=lE.actions,cE=lE.reducer;var xh="SetOutputs",Xi="ShowLoginOverlay",Tl="UserLoggedIn",gN="UserLoggedOut",eo="ApplySuggestion",wh="ApplyImageSuggestion",hN="ShowCommandPalette",Fd="ShowNicknameDialog",zd="ReduxAction",yN="RemovePinnedSuggestion",vN=e=>({[xh]:t=>{var o,s;let n=(o=e.getState().conversation.current)==null?void 0:o.externalId,r=(s=t==null?void 0:t.payload)==null?void 0:s.externalConversationId;r&&r!==n||e.dispatch(I(b({},t),{isBroadcasted:!0}))},[zd]:t=>{t.isBroadcasted||e.dispatch(I(b({},t),{isBroadcasted:!0}))},[yN]:t=>{e.dispatch(Ds(t))},[hN]:t=>{e.dispatch(ir(t.isOpen)),t.page&&e.dispatch(Yi(t.page))},[Fd]:t=>{e.dispatch(nE(t.showNicknameDialog))},[Xi]:t=>{e.dispatch(Pb(t))},[Tl]:()=>{e.dispatch(Jr())},[gN]:()=>{e.dispatch(Jr())},[wh]:t=>{e.dispatch(_d({suggestion:t.suggestion}))},[eo]:t=>{e.dispatch(kn(I(b({},t),{eventMetrics:{inputType:"mouse"},replace:"selection"})))}}),uE=vN;function Hd(e){return he("analytics/logEvent",(t,n)=>{var s,i,a;let r=(i=(s=n.getState())==null?void 0:s.conversation.current)==null?void 0:i.id,o=(a=n.getState())==null?void 0:a.info.agentInfo;return n.extra.deepdeskAPI.sendEvent(t.name,I(b({conversationId:r},o),{data:t.data}))})(e)}function Je(){let e=we();return(t,n)=>_(null,null,function*(){yield e(Hd({name:t,data:n}))})}var Qi=E(X());function Bd(e,t){let n=(0,Qi.useRef)(e);n.current=e;let[r,o]=(0,Qi.useState)(void 0),[s,i]=(0,Qi.useState)(void 0),[a,l]=(0,Qi.useState)("idle"),c=we();return{error:s,state:a,data:r,call:d=>_(null,null,function*(){l("loading"),yield c(n.current(d)).unwrap().then(p=>{o(p),l("done"),t!=null&&t.onSuccess&&(t==null||t.onSuccess(p))}).catch(p=>{i(p),l("error"),t!=null&&t.onError&&(t==null||t.onError(p))})}),reset:()=>{l("idle"),o(void 0),i(void 0)}}}var kl=E(X()),fE=E(A()),dE=kl.default.createContext(null),to=({broadcastEvents:e,children:t})=>{let n=kl.default.useMemo(()=>e,[]);return(0,fE.jsx)(dE.Provider,{value:n,children:t})},dn=()=>{let e=(0,kl.useContext)(dE);if(!e)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return e};var qd=E(X());var bh=function(e,t){return bh=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])},bh(e,t)};function Rl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");bh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Rn=function(){return Rn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Rn.apply(this,arguments)};function pE(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 Ud(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function Vd(e,t){var n=t&&t.cache?t.cache:TN,r=t&&t.serializer?t.serializer:EN,o=t&&t.strategy?t.strategy:xN;return o(e,{cache:n,serializer:r})}function SN(e){return e==null||typeof e=="number"||typeof e=="boolean"}function mE(e,t,n,r){var o=SN(r)?r:n(r),s=t.get(o);return typeof s=="undefined"&&(s=e.call(this,r),t.set(o,s)),s}function gE(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),s=t.get(o);return typeof s=="undefined"&&(s=e.apply(this,r),t.set(o,s)),s}function Eh(e,t,n,r,o){return n.bind(t,e,r,o)}function xN(e,t){var n=e.length===1?mE:gE;return Eh(e,this,n,t.cache.create(),t.serializer)}function wN(e,t){return Eh(e,this,gE,t.cache.create(),t.serializer)}function bN(e,t){return Eh(e,this,mE,t.cache.create(),t.serializer)}var EN=function(){return JSON.stringify(arguments)},CN=(function(){function e(){this.cache=Object.create(null)}return e.prototype.get=function(t){return this.cache[t]},e.prototype.set=function(t,n){this.cache[t]=n},e})(),TN={create:function(){return new CN}},Wd={variadic:wN,monadic:bN};var $d;(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"})($d||($d={}));var jd=class{constructor(t){console.warn(`[vite-messages-plugin]: Message "${t}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var Vn;(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"})(Vn||(Vn={}));var Kd;(function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"})(Kd||(Kd={}));function Ch(e){return e.type===Vn.literal}function Th(e){return e.type===Vn.argument}function Pl(e){return e.type===Vn.number}function Al(e){return e.type===Vn.date}function Il(e){return e.type===Vn.time}function _l(e){return e.type===Vn.select}function Ml(e){return e.type===Vn.plural}function hE(e){return e.type===Vn.pound}function Ol(e){return e.type===Vn.tag}function Gd(e){return!!(e&&typeof e=="object"&&e.type===Kd.number)}function Ll(e){return!!(e&&typeof e=="object"&&e.type===Kd.dateTime)}function kh(e){e.forEach(function(t){if(delete t.location,_l(t)||Ml(t))for(var n in t.options)delete t.options[n].location,kh(t.options[n].value);else Pl(t)&&Gd(t.style)||(Al(t)||Il(t))&&Ll(t.style)?delete t.style.location:Ol(t)&&kh(t.children)})}function yE(e,t){t===void 0&&(t={}),t=Rn({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new jd(e,t).parse();if(n.err){var r=SyntaxError($d[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||kh(n.val),n.val}var Hs;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(Hs||(Hs={}));var Nl=(function(e){Rl(t,e);function t(n,r,o){var s=e.call(this,n)||this;return s.code=r,s.originalMessage=o,s}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t})(Error);var Rh=(function(e){Rl(t,e);function t(n,r,o,s){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),Hs.INVALID_VALUE,s)||this}return t})(Nl);var vE=(function(e){Rl(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),Hs.INVALID_VALUE,o)||this}return t})(Nl);var SE=(function(e){Rl(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,'"'),Hs.MISSING_VALUE,r)||this}return t})(Nl);var Ft;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(Ft||(Ft={}));function kN(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==Ft.literal||n.type!==Ft.literal?t.push(n):r.value+=n.value,t},[])}function RN(e){return typeof e=="function"}function Dl(e,t,n,r,o,s,i){if(e.length===1&&Ch(e[0]))return[{type:Ft.literal,value:e[0].value}];for(var a=[],l=0,c=e;l<c.length;l++){var u=c[l];if(Ch(u)){a.push({type:Ft.literal,value:u.value});continue}if(hE(u)){typeof s=="number"&&a.push({type:Ft.literal,value:n.getNumberFormat(t).format(s)});continue}var f=u.value;if(!(o&&f in o))throw new SE(f,i);var d=o[f];if(Th(u)){(!d||typeof d=="string"||typeof d=="number")&&(d=typeof d=="string"||typeof d=="number"?String(d):""),a.push({type:typeof d=="string"?Ft.literal:Ft.object,value:d});continue}if(Al(u)){var p=typeof u.style=="string"?r.date[u.style]:Ll(u.style)?u.style.parsedOptions:void 0;a.push({type:Ft.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(Il(u)){var p=typeof u.style=="string"?r.time[u.style]:Ll(u.style)?u.style.parsedOptions:r.time.medium;a.push({type:Ft.literal,value:n.getDateTimeFormat(t,p).format(d)});continue}if(Pl(u)){var p=typeof u.style=="string"?r.number[u.style]:Gd(u.style)?u.style.parsedOptions:void 0;p&&p.scale&&(d=d*(p.scale||1)),a.push({type:Ft.literal,value:n.getNumberFormat(t,p).format(d)});continue}if(Ol(u)){var h=u.children,y=u.value,S=o[y];if(!RN(S))throw new vE(y,"function",i);var g=Dl(h,t,n,r,o,s),m=S(g.map(function(T){return T.value}));Array.isArray(m)||(m=[m]),a.push.apply(a,m.map(function(T){return{type:typeof T=="string"?Ft.literal:Ft.object,value:T}}))}if(_l(u)){var v=u.options[d]||u.options.other;if(!v)throw new Rh(u.value,d,Object.keys(u.options),i);a.push.apply(a,Dl(v.value,t,n,r,o));continue}if(Ml(u)){var v=u.options["=".concat(d)];if(!v){if(!Intl.PluralRules)throw new Nl(`Intl.PluralRules is not available in this environment.
|
|
13
13
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
14
14
|
`,Hs.MISSING_INTL_API,i);var x=n.getPluralRules(t,{type:u.pluralType}).select(d-(u.offset||0));v=u.options[x]||u.options.other}if(!v)throw new Rh(u.value,d,Object.keys(u.options),i);a.push.apply(a,Dl(v.value,t,n,r,o,d-(u.offset||0)));continue}}return kN(a)}function PN(e,t){return t?Rn(Rn(Rn({},e||{}),t||{}),Object.keys(e).reduce(function(n,r){return n[r]=Rn(Rn({},e[r]),t[r]||{}),n},{})):e}function AN(e,t){return t?Object.keys(e).reduce(function(n,r){return n[r]=PN(e[r],t[r]),n},Rn({},e)):e}function Ph(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,n){e[t]=n}}}}}function IN(e){return e===void 0&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Vd(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.NumberFormat).bind.apply(t,Ud([void 0],n,!1)))},{cache:Ph(e.number),strategy:Wd.variadic}),getDateTimeFormat:Vd(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.DateTimeFormat).bind.apply(t,Ud([void 0],n,!1)))},{cache:Ph(e.dateTime),strategy:Wd.variadic}),getPluralRules:Vd(function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new((t=Intl.PluralRules).bind.apply(t,Ud([void 0],n,!1)))},{cache:Ph(e.pluralRules),strategy:Wd.variadic})}}var Ah=(function(){function e(t,n,r,o){n===void 0&&(n=e.defaultLocale);var s=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var u=s.formatToParts(c);if(u.length===1)return u[0].value;var f=u.reduce(function(d,p){return!d.length||p.type!==Ft.literal||typeof d[d.length-1]!="string"?d.push(p.value):d[d.length-1]+=p.value,d},[]);return f.length<=1?f[0]||"":f},this.formatToParts=function(c){return Dl(s.ast,s.locales,s.formatters,s.formats,c,void 0,s.message)},this.resolvedOptions=function(){var c;return{locale:((c=s.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.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 i=o||{},a=i.formatters,l=pE(i,["formatters"]);this.ast=e.__parse(t,Rn(Rn({},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=AN(e.formats,r),this.formatters=o&&o.formatters||IN(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=yE,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 _N(e,t){return t.split(".").reduce((n,r)=>n?n[r]:void 0,e)}var MN="dummy",Ih=(0,qd.createContext)(null);function ae(e){var r;let t=(0,qd.useContext)(Ih);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,s)=>{let i=_N(n,o);return i?new Ah(i).format(s):(t!==MN&&console.warn(`${o} does not exist in messages of ${t}`),`[${o}]`)}}function Nh(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Us=Nh();function TE(e){Us=e}var Hl={exec:()=>null};function Ae(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(Yt.caret,"$1"),n=n.replace(o,i),r},getRegex:()=>new RegExp(n,t)};return r}var Yt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},ON=/^(?:[ \t]*(?:\n|$))+/,LN=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,NN=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bl=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,DN=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Dh=/(?:[*+-]|\d{1,9}[.)])/,kE=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,RE=Ae(kE).replace(/bull/g,Dh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),FN=Ae(kE).replace(/bull/g,Dh).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Fh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,zN=/^[^\n]+/,zh=/(?!\s*\])(?:\\.|[^\[\]\\])+/,HN=Ae(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",zh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),BN=Ae(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Dh).getRegex(),ef="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Hh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,UN=Ae("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Hh).replace("tag",ef).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),PE=Ae(Fh).replace("hr",Bl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ef).getRegex(),VN=Ae(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",PE).getRegex(),Bh={blockquote:VN,code:LN,def:HN,fences:NN,heading:DN,hr:Bl,html:UN,lheading:RE,list:BN,newline:ON,paragraph:PE,table:Hl,text:zN},xE=Ae("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Bl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ef).getRegex(),WN=I(b({},Bh),{lheading:FN,table:xE,paragraph:Ae(Fh).replace("hr",Bl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",xE).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ef).getRegex()}),$N=I(b({},Bh),{html:Ae(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Hh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Hl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ae(Fh).replace("hr",Bl).replace("heading",` *#{1,6} *[^
|
|
15
15
|
]`).replace("lheading",RE).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()}),jN=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,KN=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,AE=/^( {2,}|\\)\n(?!\s*$)/,GN=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tf=/[\p{P}\p{S}]/u,Uh=/[\s\p{P}\p{S}]/u,IE=/[^\s\p{P}\p{S}]/u,qN=Ae(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Uh).getRegex(),_E=/(?!~)[\p{P}\p{S}]/u,YN=/(?!~)[\s\p{P}\p{S}]/u,XN=/(?:[^\s\p{P}\p{S}]|~)/u,QN=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ME=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ZN=Ae(ME,"u").replace(/punct/g,tf).getRegex(),JN=Ae(ME,"u").replace(/punct/g,_E).getRegex(),OE="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",e2=Ae(OE,"gu").replace(/notPunctSpace/g,IE).replace(/punctSpace/g,Uh).replace(/punct/g,tf).getRegex(),t2=Ae(OE,"gu").replace(/notPunctSpace/g,XN).replace(/punctSpace/g,YN).replace(/punct/g,_E).getRegex(),n2=Ae("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,IE).replace(/punctSpace/g,Uh).replace(/punct/g,tf).getRegex(),r2=Ae(/\\(punct)/,"gu").replace(/punct/g,tf).getRegex(),o2=Ae(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),s2=Ae(Hh).replace("(?:-->|$)","-->").getRegex(),i2=Ae("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",s2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qd=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,a2=Ae(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Qd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),LE=Ae(/^!?\[(label)\]\[(ref)\]/).replace("label",Qd).replace("ref",zh).getRegex(),NE=Ae(/^!?\[(ref)\](?:\[\])?/).replace("ref",zh).getRegex(),l2=Ae("reflink|nolink(?!\\()","g").replace("reflink",LE).replace("nolink",NE).getRegex(),Vh={_backpedal:Hl,anyPunctuation:r2,autolink:o2,blockSkip:QN,br:AE,code:KN,del:Hl,emStrongLDelim:ZN,emStrongRDelimAst:e2,emStrongRDelimUnd:n2,escape:jN,link:a2,nolink:NE,punctuation:qN,reflink:LE,reflinkSearch:l2,tag:i2,text:GN,url:Hl},c2=I(b({},Vh),{link:Ae(/^!?\[(label)\]\((.*?)\)/).replace("label",Qd).getRegex(),reflink:Ae(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qd).getRegex()}),Mh=I(b({},Vh),{emStrongRDelimAst:t2,emStrongLDelim:JN,url:Ae(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/}),u2=I(b({},Mh),{br:Ae(AE).replace("{2,}","*").getRegex(),text:Ae(Mh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()}),Yd={normal:Bh,gfm:WN,pedantic:$N},Fl={normal:Vh,gfm:Mh,breaks:u2,pedantic:c2},d2={"&":"&","<":"<",">":">",'"':""","'":"'"},wE=e=>d2[e];function Ar(e,t){if(t){if(Yt.escapeTest.test(e))return e.replace(Yt.escapeReplace,wE)}else if(Yt.escapeTestNoEncode.test(e))return e.replace(Yt.escapeReplaceNoEncode,wE);return e}function bE(e){try{e=encodeURI(e).replace(Yt.percentDecode,"%")}catch(t){return null}return e}function EE(e,t){var s;let n=e.replace(Yt.findPipe,(i,a,l)=>{let c=!1,u=a;for(;--u>=0&&l[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Yt.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((s=r.at(-1))!=null&&s.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(Yt.slashPipe,"|");return r}function zl(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r;){let s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function f2(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function CE(e,t,n,r,o){let s=t.href,i=t.title||null,a=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function p2(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
@@ -80,7 +80,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
80
80
|
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
|
|
81
81
|
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 kS=E(A()),g6={green:"#0A5E52",pink:"#CD8EF2",red:"#DF341D",yellow:"#DEBD00"},LA=({className:e,color:t})=>(0,kS.jsx)("svg",{className:e,viewBox:"0 0 345 345",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,kS.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:g6[t||"pink"]})});var NA={root:"dd-LbeUM",text:"dd-Dpfn1",isLoggedIn:"dd-XvHAn",isLoggedOut:"dd-21y-z",icon:"dd-8rLqS",logo:"dd-slXhD",lock:"dd-ByzlR"};var RS={};ct(RS,{enUS:()=>h6,nlNL:()=>y6});var h6={signin:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Search"}]},y6={signin:[{type:0,value:"Log in bij "},{type:1,value:"productName"}],search:[{type:1,value:"productName"},{type:0,value:" Zoeken"}]};var Ei=E(A()),FA=({onLogIn:e})=>{let t=ae(RS),n=Q("floatingMenu"),r=Q("productName"),o=we(),s=K(kt),i=F("FloatingMenu",NA);if(s===null||n===!1)return null;let a=()=>{s===!0?o(ir(!0)):e()};return(0,Ei.jsxs)("button",{type:"button",className:(0,DA.default)(i.root,{[i.isLoggedIn]:s,[i.isLoggedOut]:!s}),onClick:a,children:[(0,Ei.jsx)("div",{className:i.text,children:t(s?"search":"signin",{productName:r})}),(0,Ei.jsxs)("div",{className:i.icon,children:[(0,Ei.jsx)(LA,{className:i.logo,color:"pink"}),s===!1&&(0,Ei.jsx)(OA,{className:i.lock})]})]})};var Dm=E(X());function jr(e){let{showMidSentenceSuggestions:t,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:r}=e.settings,{text:o,selection:s}=e.input;return s.end<e.input.suggestionTextStart||s.start!==s.end?!1:s.end>=o.length?!0:t?n&&new RegExp(n).test(o.substring(s.end))||r&&new RegExp(r).test(o.substring(0,s.end))?!0:n===!1&&r===!1:!1}var v6={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1},Am=({ui:e})=>e.overlayCollapsed,zA=Re({name:"ui",initialState:v6,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:pu,setInputFocus:Im,setOverlayCollapsed:vs,setOpenOverlayWhenTyping:HA,setOverlayCollapsedUserOverwrite:BA}=zA.actions,UA=zA.reducer;var VA={styleRow:"dd-prYfH",styleSuggestion:"dd-JTmXy"};var mu=E(A()),S6=({match:e,selected:t,styles:n})=>(0,mu.jsx)(pe,{as:"button",selected:t,className:n.styleRow,"data-testid":"style-suggestion-item",title:e.suggestion,children:(0,mu.jsx)("span",{className:n.styleSuggestion,children:e.suggestion})}),x6=({matches:e,selectedIndex:t})=>{let n=F("StyleSuggestionList",VA);return(0,mu.jsx)(Et,{children:e.map((r,o)=>(0,mu.jsx)(S6,{match:r,selected:t===o,styles:n},`${r.keyword}-${o}`))})},_m=x6;var qA=E(X());var Ss=E(X());var WA=E(X());function $A(e,t,n){(0,WA.useEffect)(()=>{let r=e.current;return r?(r.addEventListener(t,n),()=>{r.removeEventListener(t,n)}):()=>{}},[e,t,n])}var jA={root:"dd-1MBCO",actions:"dd--x4cy",closeIconContainer:"dd-1z5NR",closeIcon:"dd-8qMF-",badge:"dd-4Fpkz",formattedText:"dd-EzvTB",assistantContainer:"dd-j6o8F",formattedTextTruncated:"dd-fv169",assistantBadge:"dd-VD57E"};var gu=E(A()),KA=({title:e})=>(0,gu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18px",height:"18px",viewBox:"0 0 24 24","aria-labelledby":"closeTitle",children:[(0,gu.jsx)("title",{id:"closeTitle",children:e}),(0,gu.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})]});var PS={};ct(PS,{enUS:()=>w6,nlNL:()=>b6});var w6={assistant:[{type:0,value:"Assistant"}],close:[{type:0,value:"Close"}]},b6={assistant:[{type:0,value:"Assistent"}],close:[{type:0,value:"Sluiten"}]};var Hn=E(A()),C6=["search","personal-collection-search","search-autocomplete"];function T6(e,t,n,r={}){var s;let o="";return C6.includes(t)?o=rA(vS(e,n,{stripAgentPart:!0}),(s=r.searchKeywords)!=null?s:[n]):o=vS(e,n,r),r.placeholders===!0&&(o=oA(o)),o}var k6=()=>{},R6=({selected:e,suggestion:t})=>{let n=ae(PS),r=Q("inlineSuggestions"),o=K(Ls),[s,i]=(0,Ss.useState)(!1),a=Q("enableSuggestionFeedback"),l=K(S=>S.input.text),c=we(),u=F("TextSuggestion",jA),f=(0,Ss.useRef)(null),d=t.source==="assistant",p=a&&!d;(0,Ss.useEffect)(()=>{let S=setTimeout(()=>{c(zb({text:t.text,suggestion:t}))},500);return()=>{clearTimeout(S)}},[t]),$A(f,"click",()=>{c(kn({suggestion:t,text:t.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let h=()=>{c(Ds({source:t.source,text:t.text,assistantCode:t.assistantCode}))},y=(0,Ss.useMemo)(()=>T6(t.text,t.source,o,{stripAgentPart:r,placeholders:!0,searchKeywords:t.searchKeywords}),[r,t.text,t.source,o,t.searchKeywords]);return t.source==="gpt"&&!r?null:(0,Hn.jsxs)("div",{className:u.root,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[(0,Hn.jsx)(pe,{ref:f,as:"button","data-testid":"suggestions-overlay-item",selected:e,onClick:k6,children:t.source==="assistant"?(0,Hn.jsxs)("div",{className:u.assistantContainer,children:[(0,Hn.jsx)(gs,{containerTagName:"div",tagName:"span",className:u.formattedTextTruncated,content:y}),(0,Hn.jsx)("span",{className:u.assistantBadge,children:n("assistant")})]}):(0,Hn.jsx)(gs,{containerTagName:"div",tagName:"span",className:u.formattedText,content:y})}),p&&s&&(0,Hn.jsx)("div",{className:u.actions,children:(0,Hn.jsx)(Tm,{source:"overlay",context:l,suggestion:t})}),d&&s&&(0,Hn.jsx)("div",{className:u.closeIconContainer,children:(0,Hn.jsx)("button",{type:"button",className:u.closeIcon,onClick:h,title:n("close"),children:(0,Hn.jsx)(KA,{title:n("close")})})})]})},GA=R6;var YA=E(A()),P6=({suggestions:e,selectedIndex:t,reverse:n})=>(0,qA.useMemo)(()=>{let o=e.map((s,i)=>(0,YA.jsx)(GA,{index:i,selected:i===t,suggestion:s},`${s.text}-${s.source}`));return n?o.reverse():o},[e,t,n]),Mm=P6;var XA={root:"dd-PfvRI",paper:"dd-HYlyY"};var Om={list:{keywordMatches:[]},fetchState:"idle"},Lm=e=>e.styleSuggestions.list,Ci=he("styleSuggestions/getAll",(n,r)=>_(null,[n,r],function*({text:e},t){var l;let{deepdeskAPI:o}=t.extra,s=t.getState(),{showStyleSuggestions:i}=s.settings,a=(l=s.conversation.current)==null?void 0:l.profileCode;if(!i)return Om.list;if(!a)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:a,message:e})})),QA=Re({name:"styleSuggestions",initialState:Om,reducers:{commitStyleSuggestion(e,t){let{keyword:n,suggestion:r}=t.payload;e.list.keywordMatches=e.list.keywordMatches.filter(o=>o.keyword.toLowerCase()!==n.toLowerCase()||o.suggestion!==r)}},extraReducers:e=>{e.addCase(Ci.pending,t=>{t.fetchState="loading"}).addCase(Ci.rejected,t=>{t.fetchState="error"}).addCase(Ci.fulfilled,(t,n)=>{t.fetchState="done",zo(t.list,n.payload)||(t.list=n.payload)}).addCase(Fs,t=>{t.list=Om.list}).addCase(ut,()=>Om)}}),{commitStyleSuggestion:ZA}=QA.actions,JA=QA.reducer;var Nm=e=>{let t=new Set;return e.filter(({keyword:n,suggestion:r})=>{let o=JSON.stringify([n.toLowerCase(),r]);return t.has(o)?!1:(t.add(o),!0)})};var Ti=E(A()),A6=()=>{var S;let e=(0,Dm.useRef)(null),t=F("InlineSuggestionsOverlay",XA),n=K(jr),r=we(),o=K(kt),s=K(ji),i=K(Am),a=Q("showTextSuggestions"),l=K(Ns),c=K(bl),u=Q("showStyleSuggestions"),f=Q("showStyleSuggestionList"),d=K(Lm),p=u&&f?Nm((S=d.keywordMatches)!=null?S:[]):[],h=p.length>0,y=a&&l.length>0;return ds(()=>{setTimeout(()=>{r(vs({collapse:!0,skipWhenInputFocus:!0}))})}),(0,Dm.useEffect)(()=>{let g=e.current;if(!g||!g.parentElement)return;g.parentElement.style.left="0px";let m=g.getBoundingClientRect();g.parentElement.style.left=`${Math.min(window.innerWidth-4-m.right,0)}px`}),i||o!==!0||s===!1||!n&&!h||!y&&!h?null:(0,Ti.jsx)("div",{className:t.root,"data-variant":"inline",children:(0,Ti.jsxs)("div",{ref:e,className:t.paper,children:[h&&(0,Ti.jsx)(_m,{matches:p,selectedIndex:-1}),y&&(0,Ti.jsx)(Et,{children:(0,Ti.jsx)(Mm,{suggestions:l,selectedIndex:c})})]})})},eI=A6;var xs=E(X());var tI={root:"dd-7zvcP",dialogContent:"dd-4C0lK",continueButton:"dd-YUPQW",buttonContinueWrapper:"dd-IKpYs",nicknameInput:"dd-rxhGp",titleWrapper:"dd-nw3nD",title:"dd-5iof5",closeButtonWrapper:"dd-UUAzA",closeButton:"dd-7rjP5",buttonsWrapper:"dd-5e9Xb",errorMessage:"dd--5VgX",errorLink:"dd-u461n"};var AS={};ct(AS,{enUS:()=>I6,nlNL:()=>_6});var I6={title:[{type:0,value:"Enter your nickname"}],close:[{type:0,value:"Close"}],nicknameDialogTitle:[{type:0,value:"Please enter the name you'd like customers to see during chat conversations. This nickname will be used across your Deepdesk environment."}],nicknameDialogInputPlaceholder:[{type:0,value:"Enter your nickname"}],nicknameDialogContinueButton:[{type:0,value:"Continue"}],nicknameDialogError:[{type:0,value:"Nickname cannot be empty or spaces only"}],nicknameDialogEmojiError:[{type:0,value:"You cannot use emojis in this field."}],nicknameDialogSaveError:[{type:0,value:"We couldn't save your details just now. Please try again, or update it at "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We couldn\u2019t save your details just now. Please try again later, or update them in My Deepdesk \u2192 Settings."}]},_6={title:[{type:0,value:"Voer je bijnaam in"}],close:[{type:0,value:"Sluiten"}],nicknameDialogTitle:[{type:0,value:"Voer de naam in die je wilt dat klanten zien tijdens chatgesprekken. Deze bijnaam wordt gebruikt in je Deepdesk-omgeving."}],nicknameDialogInputPlaceholder:[{type:0,value:"Voer je bijnaam in"}],nicknameDialogContinueButton:[{type:0,value:"Doorgaan"}],nicknameDialogError:[{type:0,value:"Bijnaam mag niet leeg of alleen spaties zijn"}],nicknameDialogEmojiError:[{type:0,value:"Je kunt geen emoji's gebruiken in dit veld."}],nicknameDialogSaveError:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw of werk het bij op "},{type:1,value:"account"},{type:0,value:".deepdesk.com/admin/user-settings"}],nicknameDialogSaveErrorWithoutLink:[{type:0,value:"We konden je gegevens nu niet opslaan. Probeer het opnieuw later, of werk ze bij in My Deepdesk \u2192 Instellingen."}]};var gt=E(A()),nI=({onClose:e,onSave:t,id:n,error:r})=>{let[o,s]=(0,xs.useState)(""),[i,a]=(0,xs.useState)(!1),[l,c]=(0,xs.useState)(!1),u=F("Nickname",tI),f=xs.default.useRef(null),d=K(g=>g.info.showNicknameDialog),p=ae(AS),h=Q("adminUrl");(0,xs.useEffect)(()=>{r&&a(!0)},[r]);let y=()=>{if(!f.current)return;o.trim()?f.current.setCustomValidity(""):f.current.setCustomValidity(p("nicknameDialogError")),f.current.reportValidity()},S=g=>{g.preventDefault();let m=o.trim(),v=g.currentTarget.querySelector("#nickname-input");if(!m){v.setCustomValidity(p("nicknameDialogError")),v.reportValidity();return}v.setCustomValidity(""),t(m)};return(0,gt.jsxs)(ja,{isOpen:d,"datatest-id":n,onClose:e||(()=>{}),onBack:e||(()=>{}),children:[(0,gt.jsx)("div",{className:u.titleWrapper,children:(0,gt.jsx)("h1",{className:u.title,children:p("title")})}),(0,gt.jsxs)("form",{className:u.dialogContent,onSubmit:S,children:[(0,gt.jsx)("p",{children:p("nicknameDialogTitle")}),i&&r&&(0,gt.jsx)("div",{className:u.errorMessage,children:h?(()=>{let g=p("nicknameDialogSaveError",{account:h}),m=`${h}.deepdesk.com/admin/user-settings`,v=g.indexOf(m);if(v!==-1){let x=g.substring(0,v),T=g.substring(v+m.length);return(0,gt.jsxs)(gt.Fragment,{children:[x,(0,gt.jsx)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:u.errorLink,children:m}),T]})}return g})():p("nicknameDialogSaveErrorWithoutLink")}),(0,gt.jsx)("input",{required:!0,minLength:1,maxLength:20,"data-testid":"nickname-input",id:"nickname-input",className:u.nicknameInput,type:"text",placeholder:p("nicknameDialogInputPlaceholder"),value:o,onChange:g=>{c(new RegExp("\\p{Extended_Pictographic}","u").test(g.target.value)),s(g.target.value)},onBlur:y,ref:f}),l&&(0,gt.jsx)("div",{className:u.errorMessage,role:"alert",children:p("nicknameDialogEmojiError")}),(0,gt.jsxs)("div",{className:u.buttonsWrapper,children:[r?(0,gt.jsx)("div",{className:u.closeButtonWrapper,children:(0,gt.jsx)("button",{type:"button",className:u.closeButton,onClick:()=>e==null?void 0:e(),children:p("close")})}):null,(0,gt.jsx)("div",{className:u.buttonContinueWrapper,children:(0,gt.jsx)("button",{type:"submit",className:u.continueButton,disabled:!o.trim()||new RegExp("\\p{Extended_Pictographic}","u").test(o),children:p("nicknameDialogContinueButton")})})]})]})]})};var hu=E(A()),M6=({children:e})=>{let n=Q("locale").replace("-","");return(0,hu.jsx)(Ih.Provider,{value:n,children:e})},O6=({store:e,customStyles:t={},children:n})=>(0,hu.jsx)(Ow,{store:e,children:(0,hu.jsx)(M6,{children:(0,hu.jsx)(dl.Provider,{value:t,children:n})})}),To=O6;var zm=E(De()),Xa=E(X());var rI=E(X());function oI(e,t){let[n,r]=(0,rI.useState)(()=>{if(typeof window=="undefined")return t;try{let s=window.localStorage.getItem(e);return s?JSON.parse(s):t}catch(s){return J.error(s),t}});return[n,s=>{try{let i=s instanceof Function?s(n):s;r(i),typeof window!="undefined"&&window.localStorage.setItem(e,JSON.stringify(i))}catch(i){J.error(i)}}]}var sI=()=>/Mac/i.test(navigator.platform);var aI=E(De()),ko=E(X());var IS={};ct(IS,{enUS:()=>L6,nlNL:()=>N6});var L6={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"}]}]},N6={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 iI={root:"dd-uTPjX",anchor:"dd-C8lsZ",anchorButton:"dd-IoSx9"};var ws=E(A()),_S=(e,t,n)=>r=>(0,ws.jsx)("button",{className:e.anchorButton,type:"button",value:t,onClick:n,children:r},t),D6=({className:e,loginUrl:t,isEmbedded:n,onSnooze:r,onLogIn:o})=>{let s=ae(IS),i=dn(),a=F("Login",iI),l=Q("productName"),c=Q("signInViaPopup"),u=n&&!c,f=(0,ko.useCallback)(m=>{m.preventDefault(),r&&r(Number.parseInt(m.target.value,10))},[]),d=(0,ko.useCallback)(m=>{m.preventDefault(),i.send(Xi,!0)},[t]),p=(0,ko.useMemo)(()=>m=>(0,ws.jsx)("a",{onClick:x=>{x.preventDefault(),o()},href:t,className:a.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[t]),h=(0,ko.useCallback)(m=>(0,ws.jsx)("button",{type:"button",className:a.anchorButton,onClick:d,children:m},"prompt"),[d]),{min:y,hour:S,day:g}=(0,ko.useMemo)(()=>({min:_S(a,600,f),hour:_S(a,3600,f),day:_S(a,3600*12,f)}),[]);return(0,ws.jsxs)("div",{className:(0,aI.default)(e,a.root),children:[s("loginPlease",{login:u?h:p,productName:l}),r&&(0,ws.jsxs)(ko.Fragment,{children:[(0,ws.jsx)("br",{}),s("snooze",{min:y,hour:S,day:g})]})]})},Fm=D6;var lI={root:"dd-DoQhb",text:"dd-Jwnev"};var yu=E(A()),F6=({title:e})=>{let t=F("SearchTrigger",lI),n=we(),r=Je();return(0,yu.jsxs)("button",{type:"button",className:t.root,onClick:()=>{n(ir(!0)),r("open search",{via:"autocomplete-overlay"})},children:[(0,yu.jsx)(qa,{}),(0,yu.jsx)("span",{className:t.text,children:e})]})},cI=F6;var MS={};ct(MS,{enUS:()=>z6,nlNL:()=>H6});var z6={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"}],dismiss:[{type:0,value:"Dismiss"}],dismissError:[{type:0,value:"Dismiss error"}]},H6={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"}],dismiss:[{type:0,value:"Sluiten"}],dismissError:[{type:0,value:"Foutmelding sluiten"}]};var uI={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",loginError:"dd-KCXeb",loginErrorMessage:"dd-Bv-BG",loginErrorDismiss:"dd-iSCjU"};var Me=E(A()),B6=({onLogIn:e})=>{var $;let t=F("SuggestionsOverlay",uI),n=ae(MS),r=K(jr),o=K(Fb),s=we(),i=(0,Xa.useRef)(null),a=Q("searchTriggerKey"),l=Q("productName"),c=K(Am),u=K(kt),f=K(Tb),d=K(ji),[p,h]=(0,Xa.useState)(null),y=Q("showSearch"),S=Q("showTextSuggestions"),g=Q("adminUrl"),m=Q("isEmbedded"),v=Q("suggestionsPlacement"),[x,T]=oI("dd-snooze-until-ms",0),C=c||x>Date.now(),k=K(Ns),P=K(bl),L=Q("showStyleSuggestions"),D=Q("showStyleSuggestionList"),V=K(Lm),ne=L&&D?Nm(($=V.keywordMatches)!=null?$:[]):[],Y=ne.length>0,M=k.filter(O=>O.source!=="gpt").length,B=()=>{C&&T(0),s(BA(!C))},W=O=>{let G=Date.now()+O*1e3;T(G),J.info(`Snooze until: ${new Date(G)}`),s(vs({collapse:!0}))};return(0,Xa.useEffect)(()=>{M===0&&h(null)},[k,M]),ds(()=>{s(vs({collapse:!0,skipWhenInputFocus:!0}))}),u===null||d===!1?null:u===!1?(0,Me.jsxs)("div",{ref:i,className:(0,zm.default)(t.root,{[t.isCollapsed]:C}),children:[!C&&(0,Me.jsxs)("div",{className:t.triggers,children:[(0,Me.jsx)("div",{style:{flex:1}}),(0,Me.jsx)("div",{className:t.triggersRight,children:(0,Me.jsx)(Is,{className:t.toggleButton,title:n("collapse"),onClick:B,isCollapsed:!1})})]}),(0,Me.jsx)("div",{className:t.toggleButtonWrapper,children:(0,Me.jsx)(Is,{className:t.toggleButton,title:n("open",{productName:l}),onClick:B,isCollapsed:!0})}),(0,Me.jsxs)("div",{className:t.collapsible,children:[f&&(0,Me.jsxs)("div",{className:t.loginError,children:[(0,Me.jsx)("span",{className:t.loginErrorMessage,children:f}),(0,Me.jsx)("button",{type:"button",className:t.loginErrorDismiss,onClick:()=>s(kd()),"aria-label":n("dismissError"),children:n("dismiss")})]}),(0,Me.jsx)(Fm,{loginUrl:g,isEmbedded:m,onLogIn:e,onSnooze:W})]})]}):!o||!r&&!Y?null:(0,Me.jsxs)("div",{ref:i,className:(0,zm.default)(t.root,{[t.isCollapsed]:C}),children:[!C&&(0,Me.jsxs)("div",{className:t.triggers,children:[(0,Me.jsx)("div",{style:{flex:1},children:y&&(0,Me.jsx)("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>h(n(sI()?"searchHintMac":"searchHintWindows",{searchTriggerKey:a.toUpperCase()})),onMouseLeave:()=>h(null),children:(0,Me.jsx)(cI,{title:n("search")})})}),(0,Me.jsxs)("div",{className:t.triggersRight,onFocus:()=>{},children:[(0,Me.jsx)("div",{className:(0,zm.default)(!p&&t.hintsHidden,t.hints),children:p}),(0,Me.jsx)(Is,{className:t.toggleButton,title:n("collapse"),onClick:B,isCollapsed:!1})]})]}),(0,Me.jsx)("div",{className:t.toggleButtonWrapper,children:(0,Me.jsx)(Is,{className:t.toggleButton,title:n("open",{productName:l}),onClick:B,isCollapsed:!0})}),(Y||M>0&&S)&&(0,Me.jsxs)("div",{className:t.collapsible,onFocus:()=>{},children:[Y&&(0,Me.jsx)(_m,{matches:ne,selectedIndex:-1}),M>0&&S&&(0,Me.jsx)(Et,{children:(0,Me.jsx)(Mm,{suggestions:k,selectedIndex:P,reverse:v==="above"})})]})]})},dI=B6;var Qm=E(De());var Ao=E(X());var Qa=E(X());function Hm(e){return e.contentEditable==="true"}function U6(e){let t=0,n=0,r=window.getSelection();if(r.rangeCount!==0){let o=r.getRangeAt(0),s=o.cloneRange();s.selectNodeContents(e),s.setEnd(o.endContainer,o.endOffset),n=s.toString().length,s.selectNodeContents(e),s.setEnd(o.startContainer,o.startOffset),t=s.toString().length}return{selectionStart:t,selectionEnd:n}}function fI(e){let{selectionStart:t,selectionEnd:n}=Hm(e)?U6(e):e;return[t,n]}function pI(e){let[,t]=(0,Qa.useState)(),n=(0,Qa.useRef)(null);return n.current=fI(e),(0,Qa.useEffect)(()=>{let r=()=>{var a;let[o,s]=(a=n.current)!=null?a:[],i=fI(e);(!i||o!==i[0]||s!==i[1])&&(n.current=i,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 mI(e,t){if(!t)return;let n=e,{value:r}=n,[o,s]=t,i=r.match(ed);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=r.indexOf(l,a);return o>c&&s<c+l.length?(n.selectionStart=c,n.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}var gI=E(X()),V6=["div","span","mark","strong","b","i","u","em"];function OS(e,t,n=0){var s;let r=e[e.length-1],o=typeof r=="object"&&r!==null?(s=r.props)==null?void 0:s.tagName:void 0;if(o==="br")return e.pop(),[...e,...t,r];if(V6.includes(o)){let i=Array.isArray(r.props.children)?r.props.children:[r.props.children];return[...e.slice(0,e.length-1),(0,gI.cloneElement)(r,{children:OS(i,t,n+1)})]}return[...e,...t]}function ki(e){return e.tagName.toLowerCase()==="textarea"}var hI={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 xI=E(De());var Km=E(X());var Za=E(X());function yI(e,t){let n;return[(...r)=>{window.cancelAnimationFrame(n);let o=t?t(...r):r;n=window.requestAnimationFrame(()=>{e(...o)})},()=>window.cancelAnimationFrame(n)]}function Bm(e){let t=(0,Za.useRef)(null),[n,r]=(0,Za.useState)(!1);return(0,Za.useEffect)(()=>{var u;let o=!1,s=Number.parseFloat((u=window.getComputedStyle(document.body).zoom)!=null?u:"1"),[i,a]=yI((f,d)=>{let p=t.current;if(!p)return;let h=f/s,y=d/s,S=p.getBoundingClientRect(),g=h>S.x&&h<S.x+S.width&&y>S.y&&y<S.y+S.height;g&&!o?(o=!0,r(!0)):!g&&o&&(o=!1,r(!1))},({clientX:f,clientY:d})=>[f,d]),[l,c]=yI(()=>{o=!1,r(!1)});return e.addEventListener("mousemove",i),e.addEventListener("mouseleave",l),()=>{a(),c(),e.removeEventListener("mousemove",i),e.removeEventListener("mouseleave",l)}},[t]),[t,n]}function Um(e){return e.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Vm(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}function vI(e){return e!=null}var SI=E(De()),Wm=E(X());var Ro={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 LS=E(A()),$m=(0,Wm.forwardRef)((o,r)=>{var s=o,{className:e,children:t}=s,n=ie(s,["className","children"]);let i=(0,Wm.useRef)(null),a=F("TabCompletion",Ro);return(0,LS.jsx)("div",I(b({ref:Vm([i,r]),className:(0,SI.default)(e,a.popoverContentContainer)},n),{children:(0,LS.jsx)("div",{className:a.popoverContent,children:t})}))});var bs=E(A()),W6=e=>t=>{let n=eS(t);return"top"in n&&(n.width=e.width-(t.left-e.left)-10),n},$6=({inputElement:e,boundaryRef:t,inputStyle:n,children:r,suggestion:o})=>{let s=F("TabCompletion",Ro),i=rm(),a=(0,Km.useMemo)(()=>W6(e.getBoundingClientRect()),[e]),[l,c]=Bm(e);return(0,Km.useEffect)(()=>{c?i.open():i.close()},[c]),(0,bs.jsxs)("span",{children:[(0,bs.jsx)("mark",{ref:Vm([l,i.triggerRef]),className:(0,xI.default)(s.matchKeyword,{[s.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:r}),i.opened&&(0,bs.jsx)(Wa,{className:s.popover,triggerRef:i.triggerRef,boundaryRef:t,position:"below",align:"start",toStyle:a,children:(0,bs.jsx)($m,{style:n,children:(0,bs.jsx)("div",{className:s.hintText,children:o})})})]})},jm=class extends bo{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=>I(b({},o),{keywordRegex:new RegExp(`\\b${Um(o.keyword)}\\b`,"i")})),this.keywordMatches=r.keywordMatches),this.usedKeywordMatches.clear(),n}match(n){let r=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let i=n.match(s.keywordRegex);if(!i)return null;let a=n.charAt(i.index-1),l=n.charAt(i.index+s.keyword.length);return a==="{"&&l==="}"?null:{index:i.index,length:i[0].length,match:i[0],matchString:i[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(vI);if(r.length===0)return null;let o=r.reduce((s,i)=>i.index<s.index?i:s);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(n,r){return(0,bs.jsx)($6,{inputElement:r.inputElement,suggestion:r.suggestion,inputStyle:r.inputStyle,boundaryRef:r.boundaryRef,children:n},`keyword_${r.matchString}_${r.key}`)}asTag(){return"mark"}};var wI=E(De());var NS=E(A()),j6=({inputElement:e,children:t})=>{let n=F("TabCompletion",Ro),[r,o]=Bm(e);return(0,NS.jsx)("mark",{ref:r,className:(0,wI.default)(n.matchPlaceholder,{[n.hover]:o}),children:t})},Gm=class extends bo{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,NS.jsx)(j6,{inputElement:n.inputElement,children:t},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};var Ym=E(De());var on=E(X());var DS=E(A()),bI=()=>(0,DS.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,DS.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 Kr=E(X());var CI=E(lS());var EI={root:"dd-ky-Bv",content:"dd-kV5e1"};function qm(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(s){return null}}function FS(e){return e.replace("https://www.","").replace("https://","")}var Jn=E(A()),K6=3,G6=e=>({image:e.image||"",text:e.text,id:e.id,title:e.title}),q6=({onSelectLink:e,onDismiss:t,placeholder:n,visitUrlText:r,linkCount:o=K6})=>{let s=F("LinkSearch",EI),[i,a]=(0,Kr.useState)(""),l=we(),c=K(EA("url")),u=K(aE("URL")),f=(0,Kr.useMemo)(()=>u.map(G6),[u]),[d,p]=(0,Kr.useState)(f.length-1),h=Q("fallbackImage"),y=v=>{let x=v.target;a(x.value)},S=(v,x)=>{v.stopPropagation(),v.preventDefault(),window.open(x,"_blank")},g=v=>{var C;let x=d-1<0?f.length-1:d-1,T=d+1===f.length?0:d+1;v.code==="Escape"&&(a(""),t()),v.code==="ArrowUp"&&p(x),v.code==="ArrowDown"&&p(T),v.code==="Enter"&&e(((C=f[d])==null?void 0:C.text)||i)},m=(0,Kr.useCallback)((0,CI.default)(v=>{l(zs({query:v,type:"URL",tags:["link-search"]}))},300),[]);return(0,Kr.useEffect)(()=>{i&&m(i)},[i]),(0,Kr.useEffect)(()=>()=>{l(Dd())},[]),(0,Jn.jsxs)("div",{className:s.root,children:[(0,Jn.jsx)(Et,{withDivider:!0,children:(i?f:c).slice(0,o).map((v,x)=>(0,Jn.jsx)(pe,{selected:d===x,onClick:()=>e(v.text),"data-testid":"linksearch-suggestion",children:(0,Jn.jsxs)(be,{children:[(0,Jn.jsx)(be.Image,{src:qm(v,"small",h||void 0),title:v.title||v.text}),(0,Jn.jsxs)(be.Content,{className:s.content,cropText:!0,children:[(0,Jn.jsx)(be.Title,{children:v.title||FS(v.text)}),v.title&&FS(v.text)]}),(0,Jn.jsx)(pe.Actions,{children:(0,Jn.jsx)(pe.ActionButton,{label:r,onClick:T=>S(T,v.text)})})]})},v.text))}),(0,Jn.jsx)(qc,{value:i,onChange:y,autoFocus:!0,placeholder:n,onKeyUp:g})]})},TI=q6;var zS={};ct(zS,{enUS:()=>Y6,nlNL:()=>X6});var Y6={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}],addToPersonalCollection:[{type:0,value:"Add to Personal Collection"}]},X6={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}],addToPersonalCollection:[{type:0,value:"Toevoegen aan Personal Collection"}]};var It=E(A()),Q6=(0,on.forwardRef)((e,t)=>{let n=F("TabCompletion",Ro);return(0,It.jsx)("mark",{ref:t,className:(0,Ym.default)(n.matchSelection)},"selection-start")}),Z6=({startRef:e,boundaryRef:t,inputStyle:n,inputElement:r,children:o})=>{let s=ae(zS),i=F("TabCompletion",Ro),a=Q("addToPersonalCollection"),l=K(Zi("/admin/personal-collection/new")),c=(0,on.useRef)(null),u=(0,on.useRef)(null),[f,d]=(0,on.useState)(null),p=we(),h=rm(document.activeElement===r),[y]=(0,on.useState)(()=>document.createRange());h.triggerRef.current=y,(0,on.useEffect)(()=>()=>y.detach(),[]),(0,on.useEffect)(()=>{let g=e.current,m=c.current;!g||!m||(y.setStart(g,0),y.setEnd(m,0))},[e.current,c.current]),ds(()=>{h.close()});let S=(0,on.useCallback)(g=>{let m=y.toString(),v=/^http(s?):\/\//.test(g)?g:`https://${g}`,x=`[${m}](${v})`;p(kn({text:x,suggestion:{text:x,source:"search-url",type:"url"},eventMetrics:{inputType:"mouse"},replace:"selection"}))},[]);return(0,It.jsxs)("span",{children:[(0,It.jsx)("mark",{ref:c,className:(0,Ym.default)(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":h.opened?"true":"false",children:o}),h.opened&&(0,It.jsx)(Wa,{className:i.popoverRoot,triggerRef:h.triggerRef,boundaryRef:t,position:"above",align:"start",children:(0,It.jsxs)($m,{style:n,ref:u,children:[(0,It.jsxs)("div",{className:(0,Ym.default)(i.selectionOptions,{[i.selectionOptionsIsHidden]:f!==null}),children:[(0,It.jsxs)("button",{type:"button",tabIndex:f===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>d("insertLink"),children:[(0,It.jsx)(bI,{}),(0,It.jsx)("span",{children:"\xA0"}),(0,It.jsx)("span",{children:s("insertLink")})]}),a&&l&&(0,It.jsx)("button",{type:"button",tabIndex:f===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>{let g=y.toString(),m=`${l}?text=${encodeURIComponent(g)}`;window.open(m,"_blank")},children:(0,It.jsx)("span",{children:s("addToPersonalCollection")})})]}),f==="insertLink"&&(0,It.jsx)(TI,{placeholder:s("linkInputPlaceholder"),visitUrlText:s("visitUrl"),onSelectLink:S,onDismiss:()=>{d(null),h.close()}})]})})]},"selection-end")},Xm=class extends bo{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,on.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 s=this.foundIndex===0?r:o,i=s>=this.charCount&&s<=this.charCount+n.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;i&&this.foundIndex++;let a=this.foundIndex===1;return i&&a?this.charCount+=s-this.charCount:this.charCount+=n.length,i?b({isStart:a},i):null}replaceWith(n,r){return r.isStart?(0,It.jsx)(Q6,{ref:this.startRef}):(0,It.jsx)(Z6,{inputElement:r.inputElement,startRef:this.startRef,boundaryRef:r.boundaryRef,inputStyle:r.inputStyle})}asTag(){return"mark"}};var Po=E(A()),J6=({enabled:e,content:t,tabText:n,showTabHint:r,showTabCompletion:o,showStyleSuggestions:s,keywordMatches:i,inputElement:a,source:l})=>{let c=F("TabCompletion",hI),u=Q("insertLink"),f=Q("addToPersonalCollection"),d=Q("showMidSentenceSuggestions"),p=Q("inlineSuggestions"),h=pI(a),y=(0,Ao.useRef)(null),S=K(kt);(0,Ao.useEffect)(()=>{ki(a)&&h&&mI(a,h)},[h]);let g=(0,Ao.useCallback)(x=>{if(!o||!n)return x;let T=[(0,Po.jsx)("span",{className:c.resetIndent,children:"\u200B"},"u200B"),(0,Po.jsx)("span",{"data-testid":"tab-completion",className:(0,Qm.default)(c.tabText,c.resetIndent),"data-source":l,children:n},"tabText")];return r&&T.push((0,Po.jsx)("span",{className:(0,Qm.default)(c.hint,c.resetIndent),children:(0,Po.jsx)(Qu,{keyCode:"tab"},"tabHint")},"tabHint")),OS(x,T)},[o,n,r]),m=(0,Ao.useMemo)(()=>{let x=[];return(u||f)&&x.push(new Xm("selection")),x.push(new Gm("placeholders")),s&&x.push(new jm("keywords")),x},[p,u,f,s]),v=(0,Ao.useMemo)(()=>{let x=window.getComputedStyle(a);return{"--dd-color":x.color,"--dd-font-size":x.fontSize,"--dd-font-family":x.fontFamily,"--dd-font-variant":x.fontVariant}},[]);return!e||!S?null:(0,Po.jsxs)("div",{ref:x=>{x!=null&&x.parentElement&&(y.current=x==null?void 0:x.parentElement)},className:c.root,style:v,children:[(0,Po.jsx)(gs,{tagName:"span",containerTagName:"div",className:(0,Qm.default)(c.container,c.agentText),disableLineBreaks:ki(a),content:t||"\u200B",onAfterParse:g,matchers:m,selection:h,keywordMatches:i,inputElement:a,inputStyle:v,boundaryRef:y,inlineSuggestionsOnlyAtEnd:!d}),(0,Po.jsx)("br",{})]},"tab-completion")},ez=e=>{var g,m,v;let{input:t,ui:n,settings:r,styleSuggestions:o,conversation:s}=e,i=Ki({input:t}),a=(i==null?void 0:i.text)||"",l=(i==null?void 0:i.source)||"",c=(g=t.html)!=null?g:Ka(t.text),u=t.text.slice(t.suggestionTextStart,t.selection.end),f=a.indexOf(u)===0?a.slice(u.length):"",{showTabHint:d}=n,{isSupported:p}=s,{showTabCompletion:h,visible:y,showStyleSuggestions:S}=r;return{showTabHint:d,showStyleSuggestions:S,showTabCompletion:h&&jr(e),content:c,tabText:f,source:l,keywordMatches:(v=(m=o.list)==null?void 0:m.keywordMatches)!=null?v:[],enabled:y&&p!==!1}},kI=Mw(ez)(J6);var Es=E(X());var tz={token:null,interval:null},HS=he("passwordlessToken/getTemporaryPasswordlessToken",(e,t)=>_(null,null,function*(){let{deepdeskAPI:n}=t.extra;return{token:yield n.requestPasswordlessToken()}})),BS=he("passwordlessToken/pollPasswordlessToken",(e={},t)=>{let{interval:n=1e3*60*10}=e,{dispatch:r}=t;return r(HS()),setInterval(()=>r(HS()),n)}),RI=Re({name:"passwordlessToken",initialState:tz,reducers:{stopPollPasswordlessToken(e){e.interval&&clearInterval(e.interval),e.interval=null}},extraReducers:e=>{e.addCase(HS.fulfilled,(t,n)=>{t.token=n.payload.token}),e.addCase(BS.fulfilled,(t,n)=>{t.interval=n.payload})}}),{stopPollPasswordlessToken:PI}=RI.actions,AI=RI.reducer;function nz(e){return"buttonText"in e&&"eventName"in e}function II(e){if(e)return nz(e)?{label:e.buttonText,event:e.eventName,value:e.payload}:e}function rz(e){return e==null?void 0:e.map(t=>II(t))}function oz(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}var _I=un([FE,Rd],(e,t)=>(t?e.filter(o=>!o.externalConversationId||o.externalConversationId===t):e).map(o=>{var a;let s=II(o.callToAction),i=rz(o.callToActions);return I(b(b(b(b({text:o.response,title:o.name},s?{callToAction:s}:{}),i!=null&&i.length?{callToActions:i}:{}),o.message!==void 0?{message:o.message}:{}),(a=o.sources)!=null&&a.length?{sources:o.sources}:{}),{editable:o.editable,isLoading:o.isLoading,evaluationId:o.evaluationId,rule:{id:oz(o.code),label:o.code,name:o.name,description:o.name}})}));var Zm=E(X()),VS=E(De());var US=E(A()),Ja=()=>(0,US.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:(0,US.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 MI={root:"dd-WcEru",entity:"dd-LfP8y",entityText:"dd-L-v0f",iconWrapper:"dd-9Deh1",icon:"dd-tM7E2",iconClicked:"dd-EEdDL"};var Gr=E(A()),sz=({entities:e})=>{let t=F("EntitiesWidgetList",MI),[n,r]=(0,Zm.useState)(void 0),o=Je(),s=()=>{r(void 0)},i=a=>{e&&(r(e.indexOf(a)),Ir(a.text),o("entity copied",{entity:a,type:"copy"}))};return(0,Zm.useEffect)(()=>{let a=setTimeout(s,500);return()=>{clearTimeout(a)}},[n]),!e||e.length===0?null:(0,Gr.jsx)("div",{className:t.root,"data-testid":"widget-entities-list",children:e.map((a,l)=>(0,Gr.jsxs)("button",{title:a.text,className:t.entity,type:"button",onClick:()=>i(a),children:[(0,Gr.jsx)("span",{className:t.entityText,children:a.text}),(0,Gr.jsxs)("span",{className:t.iconWrapper,children:[(0,Gr.jsx)("span",{className:(0,VS.default)(t.icon),children:(0,Gr.jsx)(Ja,{})}),(0,Gr.jsx)("span",{className:(0,VS.default)(t.icon,n===l&&t.iconClicked),children:(0,Gr.jsx)(Ja,{})})]})]},a.text))})},OI=sz;var WS=E(A()),LI=()=>(0,WS.jsx)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,WS.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 UI=E(X());var NI={root:"dd-ohnXe",trigger:"dd-7i-S3",button:"dd-t53Cg",nav:"dd-qZFnm",item:"dd-FZC0F"};var DI={root:"dd-nazq3",rotation:"dd-3EHTv"};var zI=E(A()),iz=({size:e=12})=>{let t=F("LoadingSpinner",DI);return(0,zI.jsx)("span",{"data-testid":"loading-spinner",style:{width:`${e}px`,height:`${e}px`},className:t.root})},FI=iz;var $S=E(A()),HI=()=>(0,$S.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 512 512",fill:"currentColor",children:(0,$S.jsx)("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var vu=E(A()),BI=e=>(0,vu.jsxs)("svg",I(b({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 448 512","aria-labelledby":"checkTitle"},e),{children:[(0,vu.jsx)("title",{id:"checkTitle",children:"Check"}),(0,vu.jsx)("path",{fill:"#666",d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"})]}));var jS={};ct(jS,{enUS:()=>az,nlNL:()=>lz});var az={error:[{type:0,value:"Something went wrong"}]},lz={error:[{type:0,value:"Er ging iets fout"}]};var Bn=E(A()),cz=3e3,uz=({assistantOptions:e})=>{let t=F("OnDemandAssistants",NI),n=ae(jS),r=(0,UI.useRef)(),o=we(),s=Bd(fn),i=K(WP),a=Je(),l=i.filter(d=>d.isPinned),c=i.filter(d=>!d.isPinned),u=()=>_(null,null,function*(){return e.attachments&&e.attachments.length>0?e.attachments:o(((d,p,h)=>_(null,null,function*(){let y;if(e.transcript==="in-memory-transcript"){let S=h.dynamicThunkObject.conversationQuery;if(S){let g=yield S();y=Array.isArray(g)?g:void 0}}else Array.isArray(e.transcript)&&(y=e.transcript);return jh({transcript:y})})))}),f=d=>_(null,null,function*(){clearTimeout(r.current);let p=yield u();a("trigger on demand assistant",{assistantCode:d}),yield s.call(b(I(b({},e),{assistantCode:d}),p.length>0?{attachments:p}:{})),r.current=setTimeout(()=>s.reset(),cz)});return i.length===0?null:(0,Bn.jsxs)("div",{className:t.root,children:[l.map(({assistant:d,assistantName:p,displayName:h})=>(0,Bn.jsx)("button",{type:"button",className:t.button,disabled:s.state==="loading",onClick:()=>f(d),children:h||p},d)),c.length>0&&(0,Bn.jsxs)(Xe,{placement:"top-end",children:[(0,Bn.jsx)(Xe.Trigger,{className:t.trigger,disabled:s.state==="loading",children:(0,Bn.jsx)(Cm,{"data-testid":"trigger"})}),(0,Bn.jsx)(Xe.Content,{className:t.nav,"data-testid":"popover",children:c.map(({assistant:d,assistantName:p,displayName:h})=>(0,Bn.jsx)(Xe.Button,{className:t.item,disabled:s.state==="loading",onClick:()=>f(d),children:h||p},d))})]}),s.state==="loading"&&(0,Bn.jsx)(FI,{}),s.state==="done"&&(0,Bn.jsx)(BI,{"data-testid":"trigger-done"}),s.state==="error"&&(0,Bn.jsx)(cP,{trigger:(0,Bn.jsx)(HI,{}),children:n("error")})]})},VI=uz;var Ri=E(X());var Su={};ct(Su,{enUS:()=>dz,nlNL:()=>fz});var dz={useCue:[{type:0,value:"Add to message"}],__summarizerAssistant__:[{type:0,value:"Summary"}],copyCue:[{type:0,value:"Copy"}],removeCue:[{type:0,value:"Close"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]},fz={useCue:[{type:0,value:"Voeg toe aan bericht"}],__summarizerAssistant__:[{type:0,value:"Samenvatting"}],copyCue:[{type:0,value:"Kopi\xEBren"}],removeCue:[{type:0,value:"Sluiten"}],thumbsUp:[{type:0,value:"Thumbs up"}],thumbsDown:[{type:0,value:"Thumbs down"}]};var KS={title:"dd-YBHrC",fadeup:"dd-cRM0K",fadedown:"dd-7D4Pq",selected:"dd-bueui",actions:"dd-9Iqn9",ctaMessage:"dd-ge8nB",thumbsUp:"dd-6QwVx",thumbsDown:"dd-d3E8l",form:"dd-sPNU2",formInput:"dd-F3E4I",formSubmit:"dd-vw5S0",actionButton:"dd-cCWyJ",editableCue:"dd-nWSD-",inputSpace:"dd-DGYB1"};var _t=E(A()),pz=500,mz=100,gz=({content:e,onChange:t,onCopy:n})=>{let r=(0,Ri.useRef)(null),o=F("WidgetCue",KS);return(0,Ri.useEffect)(()=>{let s=r.current;if(!s)return;s.style.setProperty("height","0px");let i=Math.min(Math.max(s.scrollHeight,mz),pz);s.style.setProperty("height",`${i}px`)},[e]),(0,_t.jsx)("textarea",{ref:r,className:o.editableCue,onCopy:n,onChange:t,value:e})},hz=({cue:e,onCallToAction:t,onRemove:n,onCopy:r,onUse:o,onSourceClick:s})=>{var S;let i=F("WidgetCue",KS),a=ae(Su),l=Je(),c=Q("hasKeyboardInput"),[u,f]=(0,Ri.useState)(e.text),d=g=>{let m=g?I(b({},e),{callToAction:g}):e;t&&t(u,m),n(e)},p=(g,m)=>{r&&r(g,e),m&&Bo(m,i.fadeup)},h=g=>{o&&o(g,e)},y=g=>{g.preventDefault(),g.stopPropagation(),n(e)};return(0,Ri.useEffect)(()=>{l("Assistant response displayed",{evaluationId:e.evaluationId,assistantCode:e.rule.label,assistantOutput:e.text})},[]),(0,_t.jsxs)(pe,{"data-testid":"cue",children:[(0,_t.jsx)(be,{children:(0,_t.jsxs)(be.Content,{children:[e.title&&(0,_t.jsx)(be.Title,{className:i.title,"data-testid":"widget-cue-title",children:e.rule.label.startsWith("__")?a(e.rule.label):e.title}),e.message&&(0,_t.jsx)("p",{className:i.ctaMessage,children:e.message}),e.editable?(0,_t.jsx)(gz,{content:u,onCopy:()=>{let g=document.getSelection();g&&p(g.toString())},onChange:g=>{var m;return f((m=g.target.value)!=null?m:"")}}):(0,_t.jsx)(gi,{content:e.text,sources:e.sources,onSourceClick:g=>s==null?void 0:s(g,e),useLabel:a("useCue"),copyLabel:a("copyCue"),onCopy:p,onUse:c?h:void 0})]})}),(0,_t.jsxs)(pe.ButtonsContainer,{children:[(0,_t.jsxs)("div",{className:i.actions,children:[(0,_t.jsx)(pe.Button,{onClick:g=>{var m;return p((m=nf(u,"reply")[0])!=null?m:u,g.target)},variant:"primary",children:a("copyCue")}),e.callToAction&&(0,_t.jsx)(pe.Button,{onClick:()=>d(),variant:"primary",children:e.callToAction.label}),(S=e.callToActions)==null?void 0:S.map((g,m)=>(0,_t.jsx)(pe.Button,{onClick:()=>d(g),variant:"primary",children:g.label},`${g.event}-${g.label}-${m}`)),(0,_t.jsx)(pe.Button,{onClick:y,variant:"secondary",children:a("removeCue")})]}),(0,_t.jsx)(df,{evaluationId:e.evaluationId,assistantCode:e.rule.label,assistantOutput:e.text,feedbackType:"assistant"})]})]})},WI=hz;var el=E(A()),yz=({cues:e})=>{let t=we(),n=dn(),r=ae(Su),o=Je(),s=u=>{t(of({code:u.rule.label})),o("Assistant response closed",{evaluationId:u.evaluationId,assistantCode:u.rule.label,assistantOutput:u.text})},i=(u,f)=>{Ir(u),o("Assistant response copied",{evaluationId:f.evaluationId,assistantCode:f.rule.label,assistantOutput:f.text,copiedText:u})},a=(u,f)=>{var d;f.callToAction&&(t(rf(f)),o("Assistant call to action",{evaluationId:f.evaluationId,assistantCode:f.rule.label,assistantOutput:f.text,eventName:f.callToAction.event,value:(d=f.callToAction.value)!=null?d:u}))},l=(u,f)=>{var d;n.send(eo,{text:u,suggestion:{source:"assistant",assistantCode:(d=f.rule)==null?void 0:d.label,sourceText:u}}),o("Assistant response used",{evaluationId:f.evaluationId,assistantCode:f.rule.label,assistantOutput:f.text,usedText:u})},c=(u,f)=>{o("Assistant source clicked",{evaluationId:f.evaluationId,assistantCode:f.rule.label,source:u})};return(0,el.jsx)(el.Fragment,{children:e.map(u=>u.isLoading?(0,el.jsx)(sm,{title:u.rule.label.startsWith("__")?r(u.rule.label):u.title},u.rule.id):(0,el.jsx)(WI,{cue:u,onCallToAction:a,onRemove:s,onCopy:i,onUse:l,onSourceClick:c},u.evaluationId))})},$I=yz;var Jm=E(X());var jI={root:"dd-cvTAY",label:"dd-QWQxD",value:"dd-WSUHF",copyButton:"dd-67o9H",copyButtonText:"dd-oos-l",isTrue:"dd--1g2O",isFalse:"dd-sz2ir"};var bn=E(A());function vz(e,t){return t.split(".").reduce((n,r)=>!n||typeof n!="object"||!(r in n)?null:n[r],e)}var KI=({data:e,schema:t})=>{let n=F("WidgetCustomData",jI),r=o=>{Ir(o)};return(0,Jm.useEffect)(()=>{J.info("Custom data",e,t)},[e]),(0,bn.jsx)("dl",{className:n.root,children:t.map(o=>{let s=vz(e,o.path);return(0,bn.jsxs)(Jm.Fragment,{children:[(0,bn.jsx)("dt",{className:n.label,children:o.label}),(0,bn.jsx)("dd",{className:n.value,children:o.type==="boolean"&&s?(0,bn.jsx)("span",{className:n.isTrue,children:o.trueValue}):o.type==="boolean"&&!s?(0,bn.jsx)("span",{className:n.isFalse,children:o.falseValue}):o.type==="array"&&Array.isArray(s)&&s.length>0?(0,bn.jsxs)("button",{type:"button",onClick:()=>r(s.join(", ")),className:n.copyButton,children:[(0,bn.jsx)("span",{className:n.copyButtonText,children:s.join(", ")}),(0,bn.jsx)(Ja,{})]}):typeof s=="string"||typeof s=="number"?(0,bn.jsxs)("button",{type:"button",onClick:()=>r(`${s}`),className:n.copyButton,children:[(0,bn.jsx)("span",{className:n.copyButtonText,children:s}),(0,bn.jsx)(Ja,{})]}):"-"})]},o.label)})})};var qI=E(X());var Sz=/(https?:\/\/[^\s]+)/,GI=e=>e.split(" ").find(t=>Sz.test(t));var er=E(A()),xz=({suggestion:e,lines:t,onUse:n})=>{var f;let r=e.text||e.url||e.message,o=GI(r),s=ae(lu),i=Q("showImages"),a=Q("fallbackImage"),l=Q("hasKeyboardInput"),c=d=>{d.preventDefault(),d.stopPropagation(),l&&n(r)},u=(0,qI.useCallback)(d=>{window.open(o,"_blank"),d.stopPropagation(),d.preventDefault()},[o]);return(0,er.jsxs)(pe,{onClick:l?c:void 0,"data-testid":"edit-suggestion",children:[(0,er.jsxs)(be,{children:[i&&e.image&&(0,er.jsx)(be.Image,{src:qm(e,"small",a||void 0),title:e.title}),(0,er.jsxs)(be.Content,{children:[e.title&&(0,er.jsx)(be.Title,{"data-testid":"widget-suggestion-title",children:e.title}),e.searchKeywords&&((f=e.searchKeywords)==null?void 0:f.length)>0&&(0,er.jsx)(pe.Labels,{labels:e.searchKeywords}),(0,er.jsx)(be.Content,{cropText:t==="single",lineClamp:t==="multiple",children:r})]})]}),(0,er.jsxs)(pe.Actions,{children:[o&&(0,er.jsx)(pe.ActionButton,{onClick:u,label:s("visitUrl")}),l&&(0,er.jsx)(pe.ActionButton,{primary:!0,onClick:c,label:s("useSuggestion")})]})]})},YI=xz;var xu=E(A()),wz=({lines:e,suggestions:t})=>{let n=dn(),r=(o,s)=>{n.send(eo,{text:o,suggestion:I(b({},s),{source:s.source,sourceText:s.text})})};return(0,xu.jsx)(xu.Fragment,{children:t.map(o=>(0,xu.jsx)(YI,{suggestion:o,lines:e,onUse:s=>r(s,o)},o.text||o.url||o.message))})},XI=wz;var wu={};ct(wu,{enUS:()=>bz,nlNL:()=>Ez});var bz={waiting:[{type:0,value:"Loading\u2026"}],waitingForConversation:[{type:0,value:"Waiting for conversation\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],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"}],close:[{type:0,value:"Close"}]},Ez={waiting:[{type:0,value:"Laden\u2026"}],waitingForConversation:[{type:0,value:"Wachten op gesprek\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],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"}],close:[{type:0,value:"Sluiten"}]};var tl={root:"dd-W9VCG",loginText:"dd--dS6t",stateText:"dd-348OC",footer:"dd-tvofr",shortcutList:"dd-MuKK-",shortcut:"dd-5CnK9",footerShortcut:"dd-dH7XJ",link:"dd-DRo0x"};var le=E(A()),QI=(e,t)=>{let n=K(kt);(0,Es.useEffect)(()=>n?t.every(r=>!!r)?e():()=>{}:()=>{},[...t,n])},Cz=({onLogIn:e})=>{let t=F("Widget",tl),n=Q("isEmbedded"),r=Q("adminUrl");return(0,le.jsx)("div",{className:t.loginText,children:(0,le.jsx)("div",{children:(0,le.jsx)(Fm,{isEmbedded:n,loginUrl:r,onLogIn:e})})},"login")},GS=({text:e})=>{let t=F("Widget",tl);return(0,le.jsx)("div",{className:t.stateText,children:(0,le.jsx)("div",{children:(0,le.jsx)("p",{children:e})})},"notification")},Tz=()=>{let e=ae(wu),t=we(),n=F("Widget",tl),r=Q("showSearch"),o=Q("isEmbedded"),s=K(Zi("/admin/")),i=dn(),a=Q("productName"),l=Je();return QI(()=>{if(o)return t(BS()),()=>{t(PI())}},[t,o]),!r&&!s?null:(0,le.jsxs)("div",{className:n.shortcutList,children:[r&&(0,le.jsx)(pe.Button,{"data-testid":"shortcut-search","aria-label":e("linkSearch"),className:n.shortcut,icon:(0,le.jsx)(qa,{}),onClick:()=>{i.send("ShowCommandPalette",{isOpen:!0}),l("open search",{via:"widget-shortcut"})},children:e("linkSearch")}),s&&(0,le.jsx)(pe.Button,{as:"a",target:"_blank",icon:(0,le.jsx)(LI,{}),href:s,"data-testid":"shortcut-studio-login","aria-label":e("linkStudioLogin",{productName:a}),className:n.shortcut,rel:"noreferrer",onClick:()=>{l("open my deepdesk",{via:"widget-shortcut"})},children:e("linkStudioLogin",{productName:a})})]})},kz=({title:e,content:t})=>{let n=ae(wu),[r,o]=(0,Es.useState)(!0);return r?(0,le.jsx)(Tr,{"data-testid":"custom-data-banner",type:"custom-data-banner",title:e,children:(0,le.jsx)(Et,{withDivider:!0,children:(0,le.jsxs)(pe,{children:[(0,le.jsx)(be,{children:(0,le.jsx)(be.Content,{children:(0,le.jsx)(gi,{content:t})})}),(0,le.jsx)(pe.ButtonsContainer,{children:(0,le.jsx)(pe.Button,{onClick:()=>o(!1),children:n("close")})})]})})}):null},Rz=()=>{let e=we(),t=K(Qc),n=K(jP),r=K(_I),o=K(Xb),s=K(Em),i=K(km),a=K(fs),l=K(Pr);return(0,Es.useEffect)(()=>{o&&!n&&J.warn("Custom data provided, but no schema.")},[o,n]),QI(()=>{t.forEach(({type:c})=>{c==="entities"?e(xr()):td.includes(c)||e(wr(c))})},[e,l,a]),(0,Es.useEffect)(()=>{r.length>0&&!t.some(c=>c.type==="cues")&&J.warn("Received cues, but cues are not configured in widget.")},[t,r]),(0,le.jsx)(Es.Fragment,{children:t.map(({type:c,title:u,amount:f,lines:d,schema:p,property:h})=>{var y,S;switch(c){case"entities":return s&&s.length>0&&(0,le.jsx)(Tr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,le.jsx)(OI,{entities:s})},c);case"cues":return r&&r.length>0&&(0,le.jsx)(Tr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,le.jsx)(Et,{withDivider:!0,children:(0,le.jsx)($I,{cues:r})})},c);case"custom-data-banner":return o&&h&&o[h]&&(0,le.jsx)(kz,{title:u,content:String(o[h])},c);case"custom-data":return o&&p&&(0,le.jsx)(Tr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,le.jsx)(Et,{withDivider:!0,children:(0,le.jsx)(KI,{data:o,schema:p})})},c);default:return((S=(y=i[c])==null?void 0:y.suggestions)==null?void 0:S.length)>0&&(0,le.jsx)(Tr,{type:c,title:u,"data-testid":`type-${c}`,children:(0,le.jsx)(Et,{withDivider:!0,children:(0,le.jsx)(XI,{lines:d,contentType:c,suggestions:i[c].suggestions.slice(0,f)||[]})})},c)}})})},qS=({children:e})=>{let t=F("Widget",tl);return(0,le.jsx)("div",{className:t.footer,children:e})},YS=({children:e})=>{let t=F("Widget",tl);return(0,le.jsx)("div",{className:t.root,"data-testid":"widget",children:e})},Pz=({onLogIn:e,knowledgeAssistOptions:t={},assistantOptions:n={transcript:"in-memory-transcript"},openAdminFeedback:r})=>{let o=ae(wu),s=K(ji),i=K(kt),a=K(Rd),l=K(fs),c=K($P("knowledge-assist")),u=K(KP);return s===!1?(0,le.jsx)(GS,{text:o("notSupported")}):i===!1?(0,le.jsx)(Cz,{onLogIn:e}):i===null?(0,le.jsx)(GS,{text:o("waiting")}):!a||!l?(0,le.jsx)(GS,{text:o("waitingForConversation")}):(0,le.jsx)(QE,{handler:r,children:(0,le.jsx)(YS,{children:(0,le.jsxs)(lm,{initialQuestion:t.initialQuestion,assistantCode:u!=null?u:void 0,evaluateKnowledgeAssistFn:Ul,children:[(0,le.jsxs)(Bi,{children:[(0,le.jsx)(Tz,{}),(0,le.jsx)(Rz,{}),c&&(0,le.jsx)(um,{title:c.title,emptyState:t.emptyState})]}),(0,le.jsxs)(qS,{children:[c&&(0,le.jsx)(cm,{}),(0,le.jsx)(VI,{assistantOptions:n})]})]})})})},ZI=Pz;function nl(e){let t=new Range;return t.selectNodeContents(e),t}function JI(e,t,n){try{return Cs(e,t,n),!0}catch(r){return!1}}function eg(e){return"tagName"in e&&(e.tagName==="DIV"||e.tagName==="P")}function tg(e){return"tagName"in e&&e.tagName==="BR"}var bu=/[\u200B-\u200D\uFEFF]/g;function Cs(e,t,n){let r=new Range;if(e.firstChild===null&&t===0&&n===0)return r.selectNodeContents(e),r;let o=0,s=!1;function i(l,c){let u=-1,f=/[\u200B-\u200D\uFEFF]/;if(!f.test(l))return c;for(let d=0;d<=l.length;d++)if(f.test(l[d])||u++,u===c)return d;throw new Error("Offset out of range")}function a(l){switch(l.nodeType){case Node.TEXT_NODE:{let c=l.textContent,u=c.replace(bu,""),f=o+u.length,d=t>=o&&t<=f,p=n>=o&&n<=f;if(d){let h=i(c,t-o);h===0&&!p?r.setStartBefore(l):r.setStart(l,h)}p&&(r.setEnd(l,i(c,n-o)),s=!0),o=f;break}case Node.ELEMENT_NODE:{if(tg(l)&&(o===t&&r.setStartBefore(l),o++,o===n)){r.setEndAfter(l),s=!0;return}for(let u=0;u<l.childNodes.length&&(a(l.childNodes[u]),!s);u++);let c=l.lastChild;eg(l)&&c&&!eg(c)&&!tg(c)&&o++;break}default:break}}if(a(e),r.startContainer===document)throw new Error("Offsets out of bound");return r}function Eu(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:s,collapsed:i}=t,a,l,c=0;function u(f){let d=f===e,p=f===n,h=f===o;switch(f.nodeType){case Node.TEXT_NODE:{let y=f.textContent;p&&(a=c+y.substring(0,r).replace(bu,"").length),h&&(l=c+y.substring(0,s).replace(bu,"").length),c+=y.replace(bu,"").length;break}case Node.ELEMENT_NODE:{if(tg(f)&&f.nextSibling){c++;break}!d&&eg(f)&&f.previousSibling&&c++;for(let y=0;y<f.childNodes.length;y++){let S=p&&y===r,g=h&&y===s;if(S&&(a=c),g&&(l=c),l!==void 0||((!S||!i)&&u(f.childNodes[y]),h&&y===s-1&&(l=c),l!==void 0))break}h&&(l=c);break}default:break}}if(u(e),l===void 0)throw new Error("Could not determine start and end");return{start:a!=null?a:l,end:l}}function Cu(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:s,collapsed:i}=t,a=0,l="";function c(u){let f=u===e,d=u===n,p=u===o;switch(d&&(a=1),u.nodeType){case Node.TEXT_NODE:{if(a!==1)return;let h=d?r:0,y=p?s:void 0;l+=u.textContent.replace(bu,"").substring(h,y);break}case Node.ELEMENT_NODE:{if(!i&&a===1&&tg(u)&&u.nextSibling){l+=`
|
|
82
82
|
`;break}!f&&!i&&a===1&&eg(u)&&u.previousSibling&&(l+=`
|
|
83
|
-
`);let h=d?r:0,y=p?Math.min(s,u.childNodes.length):u.childNodes.length;for(let S=h;S<y&&(c(u.childNodes[S]),a!==2);S++);break}default:break}p&&(a=2)}return c(e),l}var e_=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(e_||{}),Io=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedSuggestionTextStart=0;this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedSuggestionTextStart=this.getSuggestionTextStart(),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.getSuggestionTextStart(),s=this.cachedCaretPosition===null;if(!this.isActive)return;t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit");let i=t!==this.cachedText,a=n!==null&&n!==this.cachedHTML,l=o!==this.cachedSuggestionTextStart;if((i||a||l)&&(i?(this.cachedText=t,this.cachedHTML=n):a&&(this.cachedHTML=n),this.cachedSuggestionTextStart=o,s=!0,this.emit("change",{plainText:t,rawHTML:n,suggestionTextStart:o})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,s=!0,this.emit("selection",r)),!s)return;let c=this.getCaretPosition();zo(c,this.cachedCaretPosition)||(this.cachedCaretPosition=c,this.emit("caretposition",c))}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(e_).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()})}getSuggestionTextStart(){return 0}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))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}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 t_(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Pi=class extends Io{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Cu(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){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=r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let s=this.element.ownerDocument.createRange();return s.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),s.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!t_(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!t_(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Eu(this.element,n);let r=this.lastKnownSelection;if(r&&JI(this.element,r.start,r.end))return r;let o=nl(this.element);return o.collapse(!1),Eu(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Cu(this.element,Cs(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||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 Az=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function n_(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,s=window.getComputedStyle(e),i=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",Az.forEach(u=>{o[u]=s[u]}),n?e.scrollHeight>Number.parseInt(s.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),i.appendChild(r);let l=e.getBoundingClientRect(),c={top:l.top-e.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(r),c}var Ai=class extends Io{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 n_(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});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 r_(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let s=document.createElement("iframe"),i=new URL(t);return Object.entries(n).forEach(([a,l])=>{i.searchParams.append(a,l)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=r,s.title=`iframe-${e}`,s.src=i.toString(),window.document.body.appendChild(s),s}function Iz(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var XS=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()}},QS=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=r_(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()}},ZS=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(t){this.externalId!==t&&(this.cleanup(),J.info("Set externalId",t),this.externalId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new QS(t,this.deepdeskUrl,{debug:!0}):new XS(t),r=o=>{var i,a;if(o.origin!==this.deepdeskUrl)return;let s=Iz(o.data);typeof s!="object"||s.type!=="event"||s.channel!==t||(J.info("Received broadcast event",this.externalId,o),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(r),n}send(t,n,r){var i,a;J.info("Broadcast event",{externalId:this.externalId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(i=this.eventMap)[t])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(I(b({},o),{channel:this.externalId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),this.channel=void 0,t&&((r=this.defaultChannel)==null||r.close(),this.defaultChannel=void 0)}},o_=ZS;function _z(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function $e(e){return Array.isArray(e)?e.map($e):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[_z(n)]:$e(e[n])}),{}):e}function Mz(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Mt(e){return Array.isArray(e)?e.map(Mt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[Mz(n)]:Mt(e[n])}),{}):e}var rl=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Tu=e=>new Promise(t=>{setTimeout(t,e)});var br=class extends rl{constructor(){super(...arguments);this.name="ClientError"}},ng=class extends rl{constructor(){super(...arguments);this.name="ServerError"}},JS=new Map;function s_(e){return _(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t!=null&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(J.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Ii=class{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var r;this.fetch=(r=n.fetch)!=null?r:window.fetch.bind(window)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:c=!1,abortLatest:u=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:h=k=>k instanceof TypeError,retryOnResponse:y=k=>k.status>=500,version:S=null}=C,g=ie(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(c){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(JS.has(i)){r(JS.get(i));return}}let m=I(b({credentials:"include"},g),{headers:b({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(m.headers=I(b({},m.headers),{"X-CSRFToken":this.csrfToken})),typeof S=="string"&&(m.headers=I(b({},m.headers),{"X-Deepdesk-API-Version":S}));let v=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&u&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let T=()=>_(this,null,function*(){return v--,a(i,m).then(k=>_(this,null,function*(){return y(k)&&!s.isAborted&&v>0?(yield Tu(d),T()):k.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),T()):k})).catch(k=>_(this,null,function*(){if(h(k)&&!s.isAborted&&v>0)return yield Tu(d),T();throw k}))});T().then(k=>_(this,null,function*(){let P=yield s_(k);if(delete this.latestRequestByUrl[i],k.status>=500){o(new ng("Server Error",P));return}if(k.status===401){o(new br("Unauthorized",P));return}if(k.status===403){o(new br("Forbidden",P));return}if(k.status===404){o(new br("Not Found",P));return}if(k.status>=400){o(new br("Bad Request",P));return}c&&JS.set(i,P),r(P)})).catch(k=>{o(k)})})}validateToken(){return _(this,null,function*(){let t,n,r;try{({has_valid_access_token:t,is_logged_in:n,has_valid_refresh_token:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(o){return!1}if(!t){if(!r)return!1;try{yield this.refreshToken();let{is_logged_in:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return o}catch(o){return!1}}return n})}refreshToken(){let t=Date.now();return this.lastFailedRefreshAt&&t-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new br("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}postWithStatus(t,n,r){return this.requestWithStatus(t,b({method:"POST",body:JSON.stringify(n)},r))}requestWithStatus(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,T=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:f=500,refreshTokenOn401:d=!0,retryOnError:p=C=>C instanceof TypeError,retryOnResponse:h=C=>C.status>=500,version:y=null}=T,S=ie(T,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]),g=I(b({credentials:"include"},S),{headers:b({Accept:"application/json","Content-Type":"application/json"},S.headers)});this.csrfToken&&(g.headers=I(b({},g.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(g.headers=I(b({},g.headers),{"X-Deepdesk-API-Version":y}));let m=u,v=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let x=()=>_(this,null,function*(){return m--,a(i,g).then(C=>_(this,null,function*(){return h(C)&&!s.isAborted&&m>0?(yield Tu(f),x()):C.status===401&&d===!0&&v===!1?(v=!0,yield this.refreshToken(),x()):C})).catch(C=>_(this,null,function*(){if(p(C)&&!s.isAborted&&m>0)return yield Tu(f),x();throw C}))});x().then(C=>_(this,null,function*(){let k=yield s_(C);if(delete this.latestRequestByUrl[i],C.status>=500){o(new ng("Server Error",k));return}if(C.status===401){o(new br("Unauthorized",k));return}if(C.status===403){o(new br("Forbidden",k));return}if(C.status===404){o(new br("Not Found",k));return}if(C.status>=400){o(new br("Bad Request",k));return}r({status:C.status,data:k})})).catch(C=>{delete this.latestRequestByUrl[i],o(C)})})}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};var i_;(t=>{let e;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(e=t.EvaluationStatus||(t.EvaluationStatus={}))})(i_||(i_={}));function rg(e){return I(b({},$e(e)),{metadata:e.metadata})}var _i=class _i{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Ii(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,s)=>_(this,null,function*(){let i=yield r(o,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return _(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(_i.exchangeTokenPromise||(_i.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),_i.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return _(this,null,function*(){var r;yield this.preflight(),J.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Mt(t)),{metadata:(r=t.metadata)!=null?r:{}}));return rg(n)})}upsertConversation(t){return _(this,null,function*(){var u;yield this.preflight(),J.info(`Upserting conversation for session ${t.externalId} and agent ${t.agentId}`);let{status:n,data:r}=yield this.client.postWithStatus("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Mt(t)),{metadata:(u=t.metadata)!=null?u:{}}),{version:"v2"}),o=rg(r);if(n===201)return o;let{agentId:s,agentName:i,agentEmail:a,agentNickname:l,metadata:c}=t;return this.updateConversation(o.id,{agentId:s,agentEmail:a,agentName:i,agentNickname:l,metadata:c})})}getMe(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return $e(t)})}postIdentity(t){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Mt(t))})}patchMe(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Mt(t));return $e(n)})}getProfile(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return $e(n)})}getKnowledgeAssistant(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return $e(n)})}getContentTypes(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return $e(t)})}getAccount(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return $e(t)})}getPlatformConfig(t){return _(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return $e(r)})}checkUserExists(t){return _(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return _(this,arguments,function*(t,n={}){yield this.preflight(),J.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${t}`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return J.info(`Successfully retrieved conversation ${i.id} for session ${t}`),rg(i)})}isConversationSupported(r){return _(this,arguments,function*(t,n={}){J.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${t}/has_active_profile`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(t,n){return _(this,null,function*(){var s;yield this.preflight();let r=Mt(n);n.metadata&&(r.metadata=(s=n.metadata)!=null?s:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return rg(o)})}postMessages(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(r=>I(b({},Mt(r)),{metadata:r.metadata})))})}sendEvent(t,n){return _(this,null,function*(){yield this.preflight();let a=n,{data:r}=a,o=ie(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((l,[c,u])=>I(b({},l),{[c]:u}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((l,c)=>(o[c]&&(l[c]=o[c]),l),{});return this.client.post("/api/v2/events",Mt(I(b(b({},s),i),{data:r,name:t})),{version:"v2"})})}getEntities(t){return _(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:t.filter(r=>r.text)})})}getTemporaryExchangeToken(){return _(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(t){return _(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw J.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Mt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return _(this,arguments,function*(t,n={},r){if(yield this.preflight(),r==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${t}/recommend/${r}`,Mt(n),{abortLatest:!0})).map(i=>I(b({},$e(i)),{text:i.text||i.url||i.message,source:r,type:r})).filter((i,a,l)=>a===l.findIndex(c=>c.text===i.text))})}isLoggedIn(){return _(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return _(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,Mt(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,s,i)=>s===i.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return _(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return $e(n).map(r=>I(b({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return _(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Mt(t),{abortLatest:!0,version:"v2"});return $e(n)})}search(t){return _(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${t.profile}/search`,Mt(t));return $e(n)})}loginWithPassword(t,n){return _(this,null,function*(){yield this.preflight();let r=yield this.client.post("/apis/admin/session/login/",{username:t,password:n},{refreshTokenOn401:!1});return $e(r)})}logout(){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/logout/",{},{refreshTokenOn401:!1})})}requestLoginByEmail(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return $e(n)})}requestPasswordlessToken(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return $e(t.token)})}getCsrfToken(){return _(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return _(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return $e(n)})}evaluateAssistant(t,n){return _(this,null,function*(){var l,c,u;yield this.preflight();let r=new URLSearchParams;n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let o=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=f=>Mt(f),i=(l=n==null?void 0:n.transcript)==null?void 0:l.map(f=>{var d;return b({source:f.source,text:f.text},(d=f.attachments)!=null&&d.length?{attachments:f.attachments.map(s)}:{})}),a=yield this.client.post(o,b({input:(c=n==null?void 0:n.input)!=null?c:{},conversation:i},(u=n==null?void 0:n.attachments)!=null&&u.length?{attachments:n.attachments.map(s)}:{}));return $e(a)})}createAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return $e(r)})}postMessageToAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return $e(s)})}translateMessages(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Mt(t));return $e(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),s=o.match(hw);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&J.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};_i.exchangeTokenPromise=null;var _o=_i;var og=class{constructor(t){this.options=t;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,r;this.socket,this.eventListeners=new Map,this.url=t.url,this.maxReconnectAttempts=(n=t.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(r=t.reconnectInterval)!=null?r:this.reconnectInterval,this.shouldReconnect=t.shouldReconnect}connect(){let t=()=>this.cleanup();window.addEventListener("beforeunload",t),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",t)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=t=>{var n;try{let r=$e(JSON.parse(t.data));r.event&&this.eventListeners.has(r.event)&&((n=this.eventListeners.get(r.event))==null||n.forEach(o=>o(r.data)))}catch(r){console.error("Error parsing WebSocket message:",r)}},this.socket.onclose=t=>{console.log("WebSocket connection closed:",t),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=t=>{console.error("WebSocket error:",t)})}reconnect(){var t,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(t=this.socket)==null||t.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(t,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:t,data:n}))}on(t,n){this.eventListeners.has(t)||this.eventListeners.set(t,[]);let r=this.eventListeners.get(t);r&&!r.includes(n)&&r.push(n)}close(){var t;(t=this.socket)==null||t.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(t=>t()),this.cleanupCallbacks=[]}};var a_={startTime:null,stopTime:null},l_=e=>e.handlingTime,c_=Re({name:"handlingTime",initialState:a_,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(ut,()=>a_)}}),{handlingTimeStart:u_,handlingTimeStop:sg,handlingTimeReset:d_}=c_.actions,f_=c_.reducer;var p_=(e={})=>{let t=b({onAuthError:$i(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var m_=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:Ci,debounce:500},e);return o=>s=>i=>{var p;let a=o.getState().input.text,l=s(i),c=o.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((p=c.conversation.current)==null?void 0:p.id)||!u)return l;let{text:d}=c.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function Oz(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end&&e.suggestionTextStart===t.suggestionTextStart}var g_=(e={})=>{let t=b({getTextSuggestions:wr,getAutocompleteSuggestions:du,debounce:200,check:jr},e),n;return r=>o=>s=>{var y;let{input:i}=r.getState(),a=o(s),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:u}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=s.type===Rm.toString();if(!f||!c&&!u)return a;let{input:p}=l;return Oz(p,i)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let S=Ls(l);S===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(S))},d?0:t.debounce)),a}};var h_=Ci.fulfilled.toString();function Lz(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let s=e.keywordMatches.filter(l=>l.keyword===o),i=t.keywordMatches.filter(l=>l.keyword===o),a=i.length-s.length;a<=0||r.push(...i.slice(0,a))}),r}var y_=e=>t=>n=>r=>{var c;if(r.type!==h_){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let s=t.getState(),i=s.styleSuggestions.list,a=(c=s.conversation)==null?void 0:c.current;if(o===i)return;let l=Lz(o,i);r.type===h_&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Nz=sd({assistants:$E,auth:Ab,conversation:Nb,contentTypes:VP,passwordlessToken:AI,entities:hA,handlingTime:f_,info:rE,input:Gb,settings:KE,profile:GP,search:cE,styleSuggestions:JA,ui:UA,textSuggestions:kA});function v_(e){return hb({reducer:Nz,middleware:t=>{var r;let n=t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}).concat(p_()).concat(g_({debounce:200})).concat(m_({debounce:500})).concat(y_(e.deepdeskAPI));return((r=e.middleware)!=null?r:[]).reduce((o,s)=>o.concat(s),n)},preloadedState:e.preloadedState})}function S_(e,t,n){if(t==="")return null;let r=new RegExp(`\\b${Um(t)}\\b`,"gi"),o,s=null;for(;(o=r.exec(e))!==null&&!(o.index>n);)s={start:o.index,end:o.index+o[0].length};return s}var Dz=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},Fz=e=>t=>n=>r=>{var l,c,u,f,d,p;let o=t.getState(),s=Vs("inlineSuggestions")(o),i=Vs("autoSelectSuggestion")(o)||s;switch(r.type){case $i.toString():{!r.payload&&e.emit("logout",void 0);break}case Td.fulfilled.toString():{e.emit("logout",void 0);break}case xr.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(l=o.conversation.current)==null?void 0:l.id,data:{entities:r.payload}});break;case Fs.toString():e.logSendMessage(r.payload);break;case rf.toString():e.emit("call-to-action",{cue:r.payload});break;case fn.fulfilled.toString():if(!r.isBroadcasted){let{externalConversationId:h,currentExternalIdAtRequest:y}=(c=r.payload)!=null?c:{};(!h||!y||h===y)&&e.broadcast(xh,r,!1)}break;case fn.rejected.toString():break;default:break}let a=n(r);switch(r.type){case Fs.toString():e.handleAfterSendMessage(r.payload);break;case pu.toString():e.onUpdateShowTabHint(r.payload);break;case sg.toString():e.logHandlingTime();break;case Gi.toString():e.broadcast(zd,r);break;case Ds.toString():e.broadcast(zd,r);break;case of.toString():t.dispatch(Ds({source:"assistant",assistantCode:r.payload.code}));break;case"analytics/logEvent/fulfilled":{let h=o.assistants.cues.find(y=>y.code===r.meta.arg.data.assistantCode);e.emit("event",I(b({},r.meta.arg),{cue:h}));break}case kn.toString():{let{start:h,end:y}=o.input.selection;e.emit("select-suggestion",I(b({type:Dz(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:h,end:y}:{start:0,end:y}})),s&&t.dispatch(Ho([]));break}case ZA.toString():{let{keyword:h,suggestion:y,eventMetrics:S}=r.payload,{text:g,selection:m}=o.input,v=S_(g,h,(u=m==null?void 0:m.end)!=null?u:g.length);if(!v)break;e.emit("select-suggestion",{text:y,type:"style",replace:v,suggestion:{text:y,source:"style"},eventMetrics:S});break}case _d.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Ho.toString():{i&&r.payload.length>0&&t.dispatch(Md(0));break}case fn.fulfilled.toString():{let{evaluationId:h,output:y,externalConversationId:S}=r.payload,g=r.meta.arg.assistantCode;if(e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:h,assistantCode:g,assistantOutput:HE(y),externalConversationId:S,evaluationStatus:"success"}}),!r.meta.arg.skipState){let m=t.getState().assistants.cues;e.emit("cues",m)}break}case fn.rejected.toString():{let h=r.meta.arg.assistantCode,y=(p=r.meta.arg.externalConversationId)!=null?p:(d=t.getState().conversation.current)==null?void 0:d.externalId;e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:"",assistantCode:h,assistantOutput:"",externalConversationId:y,evaluationStatus:"failed"}});break}default:break}return a},x_=Fz;function ex(e){return e.toISOString().replace("T"," ").replace("Z","")}var zz=(e,t)=>t.version,w_=un([qi,Pr,l_,zz],(e,t,n,r)=>{if(!t)return J.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:s}=n;return!o||!s?(J.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:ex(o),timeStop:ex(s)}});function b_(e,t){let{text:n,metrics:{numPaste:r,pastes:o,textSuggestions:s}}=e.input,i=n.length;return{source:"agent",clientVersion:t.version,pastes:o,lenTextTotal:i,numPastes:r,suggestions:s}}var ku=class extends Error{};function Hz(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}var ig=class{constructor(){this.queues={}}push(t,n){let r=()=>{let s=this.queues[t][1];s?(this.queues[t]=[s.promise,null],s.resolve()):delete this.queues[t]};if(!this.queues[t]){let s=n().finally(r);return this.queues[t]=[s,null],s}this.queues[t][1]&&this.queues[t][1].reject(new ku("Queued async function is outdated"));let o=Hz();return this.queues[t][1]=o,o.promise.then(()=>n().finally(r))}};function tx(e,t){var s;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return tx(r,t);let o=(s=e.ownerDocument.defaultView)==null?void 0:s.frameElement;return o?tx(o,t):null}function nx(e,t){return tx(e,t)}var Bz={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},E_=(e,t)=>{var o,s,i;if(!((i=(s=(o=e.uiConfig)==null?void 0:o.widget)==null?void 0:s.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return J.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let r=e[Bz[t]];return r&&r.length>0?r.map(a=>a.code):(J.warn(`No assistant set in profile for conversation event "${t}"`),[])};function C_(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function Uz(e){return typeof e=="object"&&e!==null&&"tagName"in e}function ag(e){return Uz(e)&&(ki(e)||Hm(e))}var k_,qr=new Map,Vz=["bottom","height","left","right","top","width"],T_=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:Vz.some(n=>e[n]!==t[n]);function R_(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,...R_(t)]:[]}function P_(e,t){return!e||!t?null:I(b({},e),{top:e.top+t.top,left:e.left+t.left})}var lg=!1,A_=()=>{lg=!0;let e=[];if(qr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),qr.delete(n);return}let r=n.getBoundingClientRect();T_(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(P_,t.rect):t.rect;T_(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),qr.size===0){lg=!1;return}k_=window.requestAnimationFrame(A_)};function rx(e,t){let n=R_(e),r=[],o=n.map((s,i)=>rx(s,a=>{r[i]=a;let l=qr.get(e);if(!l)return;let c=r.reduce(P_,l.rect);l.callbacks.forEach(u=>u(c))}));return{observe(s=!0){if(o.forEach(i=>i.observe(!1)),qr.has(e)){let i=qr.get(e);i.callbacks.push(t),i.rect&&t(i.rect)}else qr.set(e,{rect:void 0,callbacks:[t],parentRects:r});s&&!lg&&A_()},unobserve(){o.forEach(i=>i.unobserve());let s=qr.get(e);if(s){let i=s.callbacks.indexOf(t);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||qr.delete(e),qr.size||(cancelAnimationFrame(k_),lg=!1)}}}}var I_,Yr=new Map,__=()=>{Yr.forEach((e,t)=>{if(!t.isConnected){Yr.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(s=>s(e.visible)))}),Yr.size!==0&&(I_=window.requestAnimationFrame(__))};function M_(e,t){return{observe(){let n=Yr.size===0;Yr.has(e)?Yr.get(e).callbacks.push(t):Yr.set(e,{visible:void 0,callbacks:[t]}),n&&__()},unobserve(){let n=Yr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Yr.delete(e),Yr.size||cancelAnimationFrame(I_)}}}}var ox=["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 sx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ol(e){return Number.parseFloat(e)}function cg(e){return Math.round(e*1e6)}function O_(e){return e/1e6}function ix(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ol(e.width),s=ol(e.borderLeftWidth),i=ol(e.borderRightWidth),a=ol(e.paddingRight),l=O_(cg(o)-cg(s)-cg(i)),c=O_(cg(r));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function Ru(e,t={}){var u,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(u=t.position)!=null?u:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",mi(n);let r=window.getComputedStyle(e),o=!0,s=()=>{n.scrollTop=e.scrollTop};sx(r,n,ox),ix(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",s));let i=M_(e,()=>{sx(r,n,ox),ix(r,e,n),s(),setTimeout(s,0)}),a,l=!0,c=rx(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(sx(r,n,ox),ix(r,e,n),s(),t.placement==="below"&&n.classList.add("below"),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),h=window.getComputedStyle(t.closestScrollElement),y=ol(h.borderTopWidth),S=ol(h.borderBottomWidth),g=p.top+y-d.top,m=d.top+d.height+-(p.top+p.height-S);n.style.clipPath=`inset(${g}px 0px ${m}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),c.observe(),i.observe(),[n,()=>{e.removeEventListener("scroll",s),c.unobserve(),i.unobserve(),n.remove()}]}function Wz(e){return e.offsetParent!==null}function L_(e){if(!Wz(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 ug(e,t,n=100){let r=L_(e);t({isVisible:r});let o=setInterval(()=>{let s=L_(e);s!==r&&(r=s,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var N_=(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){J.warn("[Deepdesk] SessionStorage is blocked by browser")}}});var ke=E(A());var D_=N_("showTabHint",!0),sl=class sl{constructor({deepdeskUrl:t,version:n=sl.version||"unknown",locale:r="en-US",token:o,fetch:s,productName:i,createCustomChannel:a,websocketClient:l=og}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new ig;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let c=t.replace(/\/api$/,"");this.deepdeskApi=new _o(c,{token:o,fetch:s}),this.version=n,this.instanceId=sl.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[x_({broadcast:(h,y,S)=>{this.broadcastEvents.send(h,y,S)},emit:(h,y)=>this.emit(h,y),handleAfterSendMessage:h=>this.handleAfterSendMessage(h),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:h=>this.logSendMessage(h),onUpdateShowTabHint:h=>D_.update(h),sendEvent:(h,y)=>this.deepdeskApi.sendEvent(h,y)})]};this.store=v_(u),this.broadcastEvents=new o_({debug:!0,deepdeskUrl:c,eventMap:uE(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new l({url:`${c}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>_(this,null,function*(){var h;return(h=kt(this.state))!=null?h:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(pu(D_.value())),this.store.dispatch(sf({locale:r,adminUrl:c,productName:i}));let f=[],d=h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(WE(h))};this.hasConversation()?y():f.push(y)};this.ws.on("assistants::direct_response",d),this.ws.on("assistants::user_notification",d),this.ws.on("assistants::response_chunk",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(VE(h))};this.hasConversation()?y():f.push(y)}),this.ws.on("assistants::suggest_as_reply",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(Gi([{text:h.payload.message,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name}]))};this.hasConversation()?y():f.push(y)});let p=this.whenConversationLoaded(()=>{var h;this.broadcastEvents.setExternalId((h=this.state.conversation.current)==null?void 0:h.externalId),f.forEach(y=>y()),f.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),f.length=0,p()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=Ns(this.state)[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}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(J.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(J.warn("Profile has not been loaded (yet)"),!0):(J.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(t){if(kt(this.state))t();else{let n=this.subscribe(kt,r=>{r&&t()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch($i(null)),this.store.dispatch(Jr()),new Promise(t=>{this.whenLoggedIn(()=>t())})}isLoggedIn(){return _(this,null,function*(){return(yield this.store.dispatch(Jr())).payload})}isConversationSupported(t,n){return _(this,null,function*(){return(yield this.store.dispatch(ph({externalId:t,options:n}))).payload})}createConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(Pd(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return _(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(Ad({externalId:t,options:n}))).payload})}upsertConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(mh(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return _(this,null,function*(){yield this.store.dispatch(gh(t))})}updateConversation(t){return _(this,null,function*(){return(yield this.store.dispatch(Id(t))).payload})}resetConversation(){this.store.dispatch(ut()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(sf(t))}setVisitorInfo(t){this.store.dispatch(Jb(t))}setCustomData(t){this.store.dispatch(eE(t))}setAgentInfo(t,n){return _(this,null,function*(){var o;yield this.store.dispatch(El(b(b({},t),n))),(o=this.state.info.agentInfo)!=null&&o.agentNickname||this.broadcastEvents.send(Fd,{showNicknameDialog:!0})})}setAgentSettings(t){return _(this,null,function*(){yield this.store.dispatch(yh(t))})}getAgentSettings(){return _(this,null,function*(){return(yield this.store.dispatch(vh())).payload})}refresh(){return _(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let t=[];return t.push(this.refreshTextSuggestions()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(Od({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()}))}notifyExternalSuggestion(t){this.store.dispatch(kn(t))}evaluateAssistant(t,n){return _(this,null,function*(){var u;let{input:r={},attachments:o=[],transcript:s,showCuesInWidget:i=!0,includeMetadata:a,externalConversationId:l}=n||{},c=yield this.store.dispatch(fn({assistantCode:t,attachments:o,transcript:s,includeMetadata:a,input:r,externalConversationId:l,skipState:!i}));if(c.error)throw new Error(`Assistant evaluation failed: ${(u=c.payload)!=null?u:c.error.message}`);return c.payload.output})}evaluateConversationAssistant(t,n){return _(this,null,function*(){var u,f,p;yield this.loadProfileConfig();let r=this.state.profile.data;if(!r&&((u=this.state.conversation.current)!=null&&u.profileCode)&&(yield this.loadProfileConfig(),r=this.state.profile.data),!r){J.warn("Can't evaluate assistant when profile is not loaded yet.");return}let o=E_(r,t),s=(f=n==null?void 0:n.showCuesInWidget)!=null?f:!0,d=n!=null?n:{},{showCuesInWidget:i}=d,a=ie(d,["showCuesInWidget"]),l=(p=n==null?void 0:n.externalConversationId)!=null?p:this.hasConversation()?this.externalId():"",c=yield Promise.all(o.map(h=>this.queues.push(h,()=>_(this,null,function*(){var S,g;let y=yield this.store.dispatch(fn(b(I(b({assistantCode:h,includeMetadata:!0},a),{skipState:!s}),n!=null&&n.attachments&&(n==null?void 0:n.attachments.length)>0?{attachments:n==null?void 0:n.attachments}:{})));if(y.error)throw new Error(`Assistant evaluation failed: ${(S=y.payload)!=null?S:y.error.message}`);return{assistantCode:h,evaluationId:y.payload.evaluationId,output:y.payload.output,externalConversationId:(g=y.payload.externalConversationId)!=null?g:l}})).catch(y=>{if(y instanceof ku)return J.warn(`Queued assistant "${h}" was outdated and dropped`),null;throw y})));if(!s)return c.filter(h=>h!==null)})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:l,showTextSuggestions:c,suggestionsPlacement:u}=this.settings,f=a||l,d=u==="inline"||u==="below"?"below":"above",p=o.length>0;if(this.store.dispatch(Bb(hh(t))),!jr(this.state)||t.key!=="Tab"&&!c)return;let h=()=>{n||!p||i&&(t.shiftKey||(this.store.dispatch(Wb()),t.preventDefault()))},y=()=>{n||!p||f&&s<=0||i&&(t.shiftKey||(this.store.dispatch($b()),t.preventDefault()))};switch(t.key){case"ArrowUp":d==="below"?y():h();break;case"ArrowDown":{d==="below"?h():y();break}case"Escape":{n||(this.store.dispatch(Md(-1)),this.store.dispatch(vs({collapse:!0})),this.store.dispatch(HA(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let S=Ki(this.state);if(!S)return;this.store.dispatch(pu(!1)),this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(f||this.state.input.selectedSuggestionIndex===-1)return;let S=Ki(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(f||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let S=Ki(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(vs({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Ho([]))}handlingTimeStart(){this.state.handlingTime.startTime||(J.info("Start handling time"),this.store.dispatch(u_()))}handlingTimeStop(){this.state.handlingTime.startTime&&(J.info("Stop handling time"),this.store.dispatch(sg()))}logSendMessage(t){let n=b_(this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let t=w_(this.state,{version:this.version});t&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:t}),this.store.dispatch(d_()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Fs((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(Kb()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(s){J.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),J.error(s)}})}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}setPlatformVariables(t){this.store.dispatch(tE(t))}whenConversationLoaded(t){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());return n(this.state)&&r(),this.subscribe(n,s=>{s&&r()})}overlayContainerFactory(t,n,r,o){let[s,i]=Ru(n,r);return s.setAttribute("translate","no"),s.dataset.testid=t,o&&s.classList.add(o),[s,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 s=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[l,c]=Ru(s,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{c()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return mi(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),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),J.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()?(J.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(jb(r.metrics))):J.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(!ag(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=d,l=ie(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),c={customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),mi(t),this.inputMediator=a||(ki(t)?new Ai(t):new Pi(t)),this.inputMediator.on("change",({plainText:p,rawHTML:h,suggestionTextStart:y})=>{this.store.dispatch(Od({text:p,html:h,suggestionTextStart:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(Ub(hh(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:h})=>{this.store.dispatch(Vb({text:p,selectionText:h}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(Hb(p))});let u;this.inputMediator.on("selection",p=>{clearTimeout(u),p===null?u=setTimeout(()=>{p!==null&&this.store.dispatch(Ld(p))},500):this.store.dispatch(Ld(p))}),this.unmountHandlers.push(()=>{clearTimeout(u)}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Im(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Im(!0))}),this.renderSuggestions(t,c),this.subscribe(Vs("inlineSuggestions"),()=>{this.renderSuggestions(t,c)}),this.subscribe(Vs("suggestionsPlacement"),()=>{this.renderSuggestions(t,c)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(Od({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()})),this.store.dispatch(Ld(this.inputMediator.getSelection())),this.store.dispatch(Im(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(t){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let r=(0,Mo.createRoot)(n),o=null,s=a=>{o=a,i()},i=()=>{r==null||r.render((0,ke.jsx)(To,{store:this.store,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(nI,{id:"deepdesk-nickname-dialog",error:o,onSave:a=>_(this,null,function*(){try{yield this.store.dispatch(Qb({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(Fd,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(l){J.error("Error setting agent nickname",l),s("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{r.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o,s;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.belowSuggestions)==null||r.unmount(),(o=this.floatingMenu)==null||o.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(s=this.inputMediator)==null||s.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(t=>t()),this.disposeHandlers=[],this.off()}renderSuggestions(t,n){var r,o,s,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(t,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(t,n,"above")}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret"),s=(0,Mo.createRoot)(o);s.render((0,ke.jsx)(To,{store:this.store,customStyles:r,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(eI,{})})}));let i=a=>{a?(o.style.display="block",o.style.top=`${a.top}px`,o.style.left=`${a.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),o.remove()}}}renderAboveOrBelowSuggestions(t,n,r){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&nx(t,s)||void 0,[l,c]=this.overlayContainerFactory("deepdesk-tab-completion",a||t,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},o==null?void 0:o.rootNode),[u,f]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||t,{appendTo:i,placement:r},o==null?void 0:o.suggestionsRootNode),d=(0,Mo.createRoot)(l);d.render((0,ke.jsx)(To,{store:this.store,customStyles:o,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(kI,{inputElement:t})})}));let p=(0,Mo.createRoot)(u);return p.render((0,ke.jsx)(To,{store:this.store,customStyles:o,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(dI,{onLogIn:()=>this.loginViaPopup().catch(h=>J.warn(h.message))})})})),{unmount(){d.unmount(),p.unmount(),c(),f()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:s,floatingMenuParent:i}=n,a=o&&nx(t,o)||void 0,[l,c]=this.overlayContainerFactory("floating-menu",a||t,{appendTo:i!=null?i:s},r==null?void 0:r.floatingMenuParent),u=(0,Mo.createRoot)(l);return u.render((0,ke.jsx)(To,{store:this.store,customStyles:r,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(FA,{onLogIn:()=>this.loginViaPopup().catch(f=>J.warn(f.message))})})})),{unmount(){u.unmount(),c()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays"),o=(0,Mo.createRoot)(r);return o.render((0,ke.jsx)(To,{store:this.store,customStyles:n,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(MA,{})})})),{unmount(){o.unmount(),r.remove()}}}renderWidget(t,n={}){if(this.widgetElement&&J.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:s,signInViaPopup:i,ssoUrl:a,openAdminFeedback:l}=n;this.widgetElement=t,this.configure({showImages:o,isEmbedded:s,signInViaPopup:i});let c;if(a)try{c={url:new URL(a,this.settings.adminUrl).toString()}}catch(u){J.warn(`Invalid ssoUrl '${a}' passed to renderWidget`)}this.widgetRoot=(0,Mo.createRoot)(t),this.widgetRoot.render((0,ke.jsx)(To,{store:this.store,customStyles:r,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(ZI,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,openAdminFeedback:l,onLogIn:()=>this.loginViaPopup(c).catch(u=>J.warn(u.message))})})}))}unmountWidget(){var t,n;(n=(t=this.widgetRoot)==null?void 0:t.unmount)==null||n.call(t),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:s}=r,i=(0,Mo.createRoot)(n);return i.render((0,ke.jsx)(To,{store:this.store,customStyles:o,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(YS,{children:(0,ke.jsxs)(lm,{assistantCode:t,initialQuestion:s,evaluateKnowledgeAssistFn:Ul,children:[(0,ke.jsx)(Bi,{children:(0,ke.jsx)(um,{title:r.title,emptyState:r.emptyState})}),(0,ke.jsx)(qS,{children:(0,ke.jsx)(cm,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(t){let n=ug(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){C_(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){var t;return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(t=this.state.conversation.current)!=null&&t.profileCode?(this.loadProfileConfigPromise=Promise.resolve().then(()=>_(this,null,function*(){yield this.store.dispatch(Xc()).unwrap();let n=fs(this.state);n&&this.store.dispatch(sf({showSearch:n.search,showImageSearch:n.imageSearch,showEntitiesCommand:n.entitiesCommand,showSummaryCommand:!!n.summarizerAssistantNew,showKnowledgeSearch:!!n.knowledgeAssistantNew||!!n.knowledgeAssistant,recommendTextSuggestions:n.recommendTextSuggestions}))})).finally(()=>{fs(this.state)||(this.loadProfileConfigPromise=null)}),this.loadProfileConfigPromise):Promise.resolve()}loginViaPopup(t){return _(this,null,function*(){return new Promise((n,r)=>{this.store.dispatch(kd());let o=new MessageChannel,s=o.port1,i=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",f),clearInterval(d)};s.onmessage=p=>_(this,null,function*(){var h,y;if((h=p.data)!=null&&h.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Tl),l=!0,o.port1.close(),n()}catch(S){console.error(S),r(S)}finally{l=!0,c()}});let u=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");if(u===null){r(new Error("Popup blocked by browser"));return}let f=p=>_(this,null,function*(){var h;if(!(p.origin!==a.origin||p.source!==u))switch((h=p.data)==null?void 0:h.type){case"deepdesk-popup-request-origin":{try{let y=JSON.stringify({type:"deepdesk-popup-parent-origin"});u.postMessage(y,a.origin)}catch(y){J.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});u.postMessage(y,a.origin,[o.port2])}catch(y){J.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{if(c(),p.data.message==="Platform account url mismatch"){let y="Please contact your administrator: The page that opened the popup is not a trusted origin.";J.warn(y),this.store.dispatch(uh(y)),r(new Error(y));return}if(p.data.message==="Timeout"){let y="Please contact your administrator: Popup timed out. Check if the account's platform.url or account.url is configured correctly.";J.warn(y),this.store.dispatch(uh(y)),r(new Error(y));return}r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{u&&!u.closed||(c(),l||r(new Error("Popup closed by user")))},200);this.disposeHandlers.push(c)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}refreshTextSuggestions(){return _(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Rm()))})}refreshWidgetSuggestions(){return _(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Qc(this.state);try{n.forEach(({type:r})=>{switch(r){case"entities":this.store.dispatch(xr());break;case"pinned-messages":case"sticky-messages":break;default:td.includes(r)||this.store.dispatch(wr(r))}})}catch(r){this.handleError(r)}})}};sl.version="19.6.1",sl.count=0;var Pu=sl;function $z(e){return _(this,null,function*(){var o,s,i;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(i=(s=e.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function F_(e,t){return _(this,null,function*(){let n=yield $z(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}})}function z_(e,t,n){return _(this,null,function*(){yield new _o(e).authenticateWithKey(t,n)})}function H_(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function B_(r,o){return _(this,arguments,function*(e,t,n={}){var f,d;let{value:s}=e,{start:i,end:a}=(f=n.replace)!=null?f:{start:0,end:s.length},l=`${s.slice(0,i)}${t}${s.slice(a)}`,c=(d=n.selectionAfter)!=null?d:{start:i+t.length,end:i+t.length},u=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(u()).then(()=>{e.selectionStart=c.start,e.selectionEnd=c.end,e.blur(),e.focus()})})}function U_(r,o){return _(this,arguments,function*(e,t,n={}){let s=n.replace?Cs(e,n.replace.start,n.replace.end):nl(e),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?t.split(`
|
|
83
|
+
`);let h=d?r:0,y=p?Math.min(s,u.childNodes.length):u.childNodes.length;for(let S=h;S<y&&(c(u.childNodes[S]),a!==2);S++);break}default:break}p&&(a=2)}return c(e),l}var e_=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(e_||{}),Io=class{constructor(t){this.element=t;this.isFocused=!1;this.isActive=!0;this.isDisposed=!1;this.eventListeners={};this.disposeHandlers=[];this.cachedText="";this.cachedSuggestionTextStart=0;this.cachedCaretPosition=null;this.cachedSelection={start:0,end:0};this.cachedHTML="";this.isSubmitting=!1;this.isPossibleClearInputAction=!1;this.cachedText=this.getText(),this.cachedSuggestionTextStart=this.getSuggestionTextStart(),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.getSuggestionTextStart(),s=this.cachedCaretPosition===null;if(!this.isActive)return;t===""&&this.cachedText!==""&&!this.isPossibleClearInputAction&&this.emit("submit");let i=t!==this.cachedText,a=n!==null&&n!==this.cachedHTML,l=o!==this.cachedSuggestionTextStart;if((i||a||l)&&(i?(this.cachedText=t,this.cachedHTML=n):a&&(this.cachedHTML=n),this.cachedSuggestionTextStart=o,s=!0,this.emit("change",{plainText:t,rawHTML:n,suggestionTextStart:o})),(r.start!==this.cachedSelection.start||r.end!==this.cachedSelection.end)&&(this.cachedSelection=r,s=!0,this.emit("selection",r)),!s)return;let c=this.getCaretPosition();zo(c,this.cachedCaretPosition)||(this.cachedCaretPosition=c,this.emit("caretposition",c))}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(e_).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()})}getSuggestionTextStart(){return 0}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))}off(t,n){if(!this.eventListeners[t])return;let r=this.eventListeners[t].indexOf(n);r!==-1&&this.eventListeners[t].splice(r,1)}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 t_(e){return e.top!==0||e.left!==0||e.height!==0||e.width!==0}var Pi=class extends Io{constructor(){super(...arguments);this.lastKnownSelection=null}getRootNode(){return this.element.getRootNode()}getText(){let n=new Range;return n.selectNodeContents(this.element),Cu(this.element,n)}getHTML(){return this.element.innerHTML||""}getRange(){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=r.rangeCount>0?r.getRangeAt(0):null;if(!o)return null;let s=this.element.ownerDocument.createRange();return s.setStart(o==null?void 0:o.startContainer,o==null?void 0:o.startOffset),s.setEnd(o==null?void 0:o.endContainer,o==null?void 0:o.endOffset),!s||!this.element.contains(s.startContainer)||!this.element.contains(s.endContainer)?null:s}getCaretPosition(){let n=this.getRange();if(!n||!n.collapsed||!("getBoundingClientRect"in n))return null;let r=n.getBoundingClientRect();return!t_(r)&&(n.insertNode(this.element.ownerDocument.createTextNode("\u2060")),r=n.getBoundingClientRect(),n.deleteContents(),!t_(r))?null:{top:r.top+r.height,left:r.left}}getSelection(){let n=this.getRange();if(n)return Eu(this.element,n);let r=this.lastKnownSelection;if(r&&JI(this.element,r.start,r.end))return r;let o=nl(this.element);return o.collapse(!1),Eu(this.element,o)}getSelectedText(){let{start:n,end:r}=this.getSelection();return Cu(this.element,Cs(this.element,n,r))}listen(){super.listen();let n=new MutationObserver(s=>{var i,a;s.length===2&&s[0].addedNodes.length===1&&((i=s[0].addedNodes[0])==null?void 0:i.textContent)==="\u2060"&&((a=s[1].removedNodes[0])==null?void 0:a.textContent)==="\u2060"||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 Az=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"];function n_(e,t){let n="mozInnerScreenX"in window,r=document.createElement("div");r.id="input-textarea-caret-position-mirror-div";let o=r.style,s=window.getComputedStyle(e),i=e.ownerDocument.body;o.whiteSpace="pre-wrap",o.wordWrap="break-word",o.position="absolute",o.visibility="hidden",Az.forEach(u=>{o[u]=s[u]}),n?e.scrollHeight>Number.parseInt(s.height)&&(o.overflowY="scroll"):o.overflow="hidden",r.textContent=e.value.substring(0,t);let a=document.createElement("span");a.textContent=e.value.substring(t)||".",r.appendChild(a),i.appendChild(r);let l=e.getBoundingClientRect(),c={top:l.top-e.scrollTop+a.offsetTop+Number.parseInt(s.borderTopWidth)+a.offsetHeight,left:l.left-e.scrollLeft+a.offsetLeft+Number.parseInt(s.borderLeftWidth)};return i.removeChild(r),c}var Ai=class extends Io{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 n_(this.element,this.element.selectionEnd)}listen(){super.listen();let n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=n==null?void 0:n.get)==null?void 0:s.call(this.element)},set:s=>{var i;(i=n==null?void 0:n.set)==null||i.call(this.element,s),this.handleInteraction()}}),this.addEventListener("scroll",()=>{this.emit("caretposition",this.getCaretPosition())});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 r_(e,t,n){let r=`deepdesk-iframe-${e}`,o=document.getElementById(r);if(o)return o;let s=document.createElement("iframe"),i=new URL(t);return Object.entries(n).forEach(([a,l])=>{i.searchParams.append(a,l)}),s.style.position="absolute",s.style.left="-999em",s.style.width="0px",s.style.height="0px",s.tabIndex=-1,s.id=r,s.title=`iframe-${e}`,s.src=i.toString(),window.document.body.appendChild(s),s}function Iz(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch(t){return e}}var XS=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()}},QS=class{constructor(t,n,r){this.name=t;this.targetOrigin=n;this.options=r;this.disposeHandlers=[];this.iframe=r_(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()}},ZS=class{constructor(t){this.params=t;this.deepdeskUrl=t.deepdeskUrl,this.eventMap=t.eventMap,this.externalId="deepdesk-general",this.defaultChannel=this.createChannel("deepdesk-general")}get isCrossOrigin(){return this.params.deepdeskUrl!==(this.params.origin||window.location.origin)}setExternalId(t){this.externalId!==t&&(this.cleanup(),J.info("Set externalId",t),this.externalId=t,this.channel=this.createChannel(t))}createChannel(t){let n=this.params.createCustomChannel?this.params.createCustomChannel(t):this.isCrossOrigin?new QS(t,this.deepdeskUrl,{debug:!0}):new XS(t),r=o=>{var i,a;if(o.origin!==this.deepdeskUrl)return;let s=Iz(o.data);typeof s!="object"||s.type!=="event"||s.channel!==t||(J.info("Received broadcast event",this.externalId,o),(a=(i=this.eventMap)[s.name])==null||a.call(i,s.payload))};return n.onMessage(r),n}send(t,n,r){var i,a;J.info("Broadcast event",{externalId:this.externalId,name:t,payload:n});let o={type:"event",name:t,payload:n};r!==!1&&((a=(i=this.eventMap)[t])==null||a.call(i,n));let s=this.externalId==="deepdesk-general"?this.defaultChannel:this.channel;s==null||s.postMessage(I(b({},o),{channel:this.externalId}))}cleanup(t=!1){var n,r;(n=this.channel)==null||n.close(),this.channel=void 0,t&&((r=this.defaultChannel)==null||r.close(),this.defaultChannel=void 0)}},o_=ZS;function _z(e){return e.replace(/(_\w)/g,t=>t[1].toUpperCase())}function $e(e){return Array.isArray(e)?e.map($e):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[_z(n)]:$e(e[n])}),{}):e}function Mz(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Mt(e){return Array.isArray(e)?e.map(Mt):typeof e=="object"&&e!==null?Object.keys(e).reduce((t,n)=>I(b({},t),{[Mz(n)]:Mt(e[n])}),{}):e}var rl=class extends Error{constructor(n,r){super(n);this.body=r;this.name="CustomError"}};var Tu=e=>new Promise(t=>{setTimeout(t,e)});var br=class extends rl{constructor(){super(...arguments);this.name="ClientError"}},ng=class extends rl{constructor(){super(...arguments);this.name="ServerError"}},JS=new Map;function s_(e){return _(this,null,function*(){if(e.status===204)return e.text().catch(()=>{}),null;let t=e.headers.get("content-type");if(t!=null&&t.includes("application/json"))return e.json();let n=yield e.text();return n===""?null:(J.warn("Unexpected response body:",n.slice(0,20)),JSON.parse(n))})}var Ii=class{constructor(t="",n={}){this.baseUrl=t;this.options=n;this.latestRequestByUrl={};this.refreshingToken=null;this.lastFailedRefreshAt=null;this.failedRefreshCooldown=1e4;var r;this.fetch=(r=n.fetch)!=null?r:window.fetch.bind(window)}patchFetch(t){this.fetch=t(this.fetch)}setCsrfToken(t){this.csrfToken=t}request(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,l=n.method===void 0||n.method.toLowerCase()==="get",C=n,{useCache:c=!1,abortLatest:u=!1,attempts:f=1,retryDelay:d=500,refreshTokenOn401:p=!0,retryOnError:h=k=>k instanceof TypeError,retryOnResponse:y=k=>k.status>=500,version:S=null}=C,g=ie(C,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]);if(c){if(!l)throw new Error(`Can't use 'useCache' for ${n.method}`);if(JS.has(i)){r(JS.get(i));return}}let m=I(b({credentials:"include"},g),{headers:b({Accept:"application/json","Content-Type":"application/json"},g.headers)});!l&&this.csrfToken&&(m.headers=I(b({},m.headers),{"X-CSRFToken":this.csrfToken})),typeof S=="string"&&(m.headers=I(b({},m.headers),{"X-Deepdesk-API-Version":S}));let v=f,x=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&u&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let T=()=>_(this,null,function*(){return v--,a(i,m).then(k=>_(this,null,function*(){return y(k)&&!s.isAborted&&v>0?(yield Tu(d),T()):k.status===401&&p===!0&&x===!1?(x=!0,yield this.refreshToken(),T()):k})).catch(k=>_(this,null,function*(){if(h(k)&&!s.isAborted&&v>0)return yield Tu(d),T();throw k}))});T().then(k=>_(this,null,function*(){let P=yield s_(k);if(delete this.latestRequestByUrl[i],k.status>=500){o(new ng("Server Error",P));return}if(k.status===401){o(new br("Unauthorized",P));return}if(k.status===403){o(new br("Forbidden",P));return}if(k.status===404){o(new br("Not Found",P));return}if(k.status>=400){o(new br("Bad Request",P));return}c&&JS.set(i,P),r(P)})).catch(k=>{o(k)})})}validateToken(){return _(this,null,function*(){let t,n,r;try{({has_valid_access_token:t,is_logged_in:n,has_valid_refresh_token:r}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1}))}catch(o){return!1}if(!t){if(!r)return!1;try{yield this.refreshToken();let{is_logged_in:o}=yield this.get("/apis/admin/session/validate/",{refreshTokenOn401:!1});return o}catch(o){return!1}}return n})}refreshToken(){let t=Date.now();return this.lastFailedRefreshAt&&t-this.lastFailedRefreshAt<this.failedRefreshCooldown?Promise.reject(new br("Unauthorized","Failed to refresh token")):this.refreshingToken?this.refreshingToken:(this.refreshingToken=this.get("/apis/admin/session/refresh/",{refreshTokenOn401:!1}).catch(n=>{throw(n==null?void 0:n.message)==="Unauthorized"&&(this.lastFailedRefreshAt=Date.now()),n}).finally(()=>{this.refreshingToken=null}),this.refreshingToken)}get(t,n){return this.request(t,n)}post(t,n,r){return this.request(t,b({method:"POST",body:JSON.stringify(n)},r))}postWithStatus(t,n,r){return this.requestWithStatus(t,b({method:"POST",body:JSON.stringify(n)},r))}requestWithStatus(t,n={}){return new Promise((r,o)=>{let s={isAborted:!1,reject:o},i=`${this.baseUrl}${t}`,a=this.fetch,T=n,{useCache:l=!1,abortLatest:c=!1,attempts:u=1,retryDelay:f=500,refreshTokenOn401:d=!0,retryOnError:p=C=>C instanceof TypeError,retryOnResponse:h=C=>C.status>=500,version:y=null}=T,S=ie(T,["useCache","abortLatest","attempts","retryDelay","refreshTokenOn401","retryOnError","retryOnResponse","version"]),g=I(b({credentials:"include"},S),{headers:b({Accept:"application/json","Content-Type":"application/json"},S.headers)});this.csrfToken&&(g.headers=I(b({},g.headers),{"X-CSRFToken":this.csrfToken})),typeof y=="string"&&(g.headers=I(b({},g.headers),{"X-Deepdesk-API-Version":y}));let m=u,v=!1;if(!a)throw new Error("fetch is not set");this.latestRequestByUrl[i]&&c&&(this.latestRequestByUrl[i].isAborted=!0,this.latestRequestByUrl[i].reject(new Error("Aborted"))),this.latestRequestByUrl[i]=s;let x=()=>_(this,null,function*(){return m--,a(i,g).then(C=>_(this,null,function*(){return h(C)&&!s.isAborted&&m>0?(yield Tu(f),x()):C.status===401&&d===!0&&v===!1?(v=!0,yield this.refreshToken(),x()):C})).catch(C=>_(this,null,function*(){if(p(C)&&!s.isAborted&&m>0)return yield Tu(f),x();throw C}))});x().then(C=>_(this,null,function*(){let k=yield s_(C);if(delete this.latestRequestByUrl[i],C.status>=500){o(new ng("Server Error",k));return}if(C.status===401){o(new br("Unauthorized",k));return}if(C.status===403){o(new br("Forbidden",k));return}if(C.status===404){o(new br("Not Found",k));return}if(C.status>=400){o(new br("Bad Request",k));return}r({status:C.status,data:k})})).catch(C=>{delete this.latestRequestByUrl[i],o(C)})})}patch(t,n,r){return this.request(t,b({method:"PATCH",body:JSON.stringify(n)},r))}put(t,n,r){return this.request(t,b({method:"PUT",body:JSON.stringify(n)},r))}delete(t,n){return this.request(t,b({method:"DELETE"},n))}};var i_;(t=>{let e;(a=>(a.SUCCESS="success",a.FAILURE="failure",a.CONDITIONS_NOT_MET="conditions_not_met",a.MAX_RECURSION_LEVEL="max_recursion_level",a.NO_ACCESS_TO_ASSISTANT="no_access_to_assistant"))(e=t.EvaluationStatus||(t.EvaluationStatus={}))})(i_||(i_={}));function rg(e){return I(b({},$e(e)),{metadata:e.metadata})}var _i=class _i{constructor(t,n={}){this.options=n;this.latestReceivedDeepdeskVersions={};this.shouldFetchCsrfToken=!0;this.client=new Ii(t,{fetch:n.fetch}),this.client.patchFetch(r=>(o,s)=>_(this,null,function*(){let i=yield r(o,s);return this.handleDeepdeskVersionHeaders(i),i}))}preflight(){return _(this,null,function*(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let t=yield this.getCsrfToken();this.client.setCsrfToken(t)}return this.options.token?(_i.exchangeTokenPromise||(_i.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),_i.exchangeTokenPromise):Promise.resolve()})}createConversation(t){return _(this,null,function*(){var r;yield this.preflight(),J.info(`Creating conversation for session ${t.externalId} and agent ${t.agentId}`);let n=yield this.client.post("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Mt(t)),{metadata:(r=t.metadata)!=null?r:{}}));return rg(n)})}upsertConversation(t){return _(this,null,function*(){var u;yield this.preflight(),J.info(`Upserting conversation for session ${t.externalId} and agent ${t.agentId}`);let{status:n,data:r}=yield this.client.postWithStatus("/api/v2/conversations",I(b({chat_start_time:new Date().toISOString()},Mt(t)),{metadata:(u=t.metadata)!=null?u:{}}),{version:"v2"}),o=rg(r);if(n===201)return o;let{agentId:s,agentName:i,agentEmail:a,agentNickname:l,metadata:c}=t;return this.updateConversation(o.id,{agentId:s,agentEmail:a,agentName:i,agentNickname:l,metadata:c})})}getMe(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/me/");return $e(t)})}postIdentity(t){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/me/identities/",Mt(t))})}patchMe(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.patch("/apis/admin/session/me/",Mt(t));return $e(n)})}getProfile(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/profiles/${t}/`,{useCache:!0});return $e(n)})}getKnowledgeAssistant(t){return _(this,null,function*(){let n=yield this.client.get(`/apis/admin/knowledge-assist/assistants/${t}/`,{useCache:!0});return $e(n)})}getContentTypes(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/content-types/",{useCache:!0});return $e(t)})}getAccount(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/account/",{useCache:!0});return $e(t)})}getPlatformConfig(t){return _(this,null,function*(){let n=t!==void 0?`/platform/config/${t}/`:"/platform/config/",{config:r}=yield this.client.get(n,{useCache:!0});return $e(r)})}checkUserExists(t){return _(this,null,function*(){let{exists:n}=yield this.client.get(`/apis/admin/users/exists?external_id=${t}`,{version:"v1"});return n})}getConversationByExternalId(r){return _(this,arguments,function*(t,n={}){yield this.preflight(),J.info(`Getting conversation for session ${t}`);let{attempts:o=1,retryDelay:s=1e3}=n,i=yield this.client.get(`/api/v2/conversations/by_external_id/${t}`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500,version:"v2"});return J.info(`Successfully retrieved conversation ${i.id} for session ${t}`),rg(i)})}isConversationSupported(r){return _(this,arguments,function*(t,n={}){J.info(`Check if conversation for session ${t} is supported`);let{attempts:o=1,retryDelay:s=1e3}=n;return(yield this.client.get(`/api/v2/conversations/by_external_id/${t}/has_active_profile`,{attempts:o,retryDelay:s,retryOnResponse:a=>a.status===404||a.status>=500})).has_active_profile})}updateConversation(t,n){return _(this,null,function*(){var s;yield this.preflight();let r=Mt(n);n.metadata&&(r.metadata=(s=n.metadata)!=null?s:{});let o=yield this.client.put(`/api/v2/conversations/${t}`,r);return rg(o)})}postMessages(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post(`/api/v2/conversations/${t}/messages`,n.map(r=>I(b({},Mt(r)),{metadata:r.metadata})))})}sendEvent(t,n){return _(this,null,function*(){yield this.preflight();let a=n,{data:r}=a,o=ie(a,["data"]),s=Object.entries(this.latestReceivedDeepdeskVersions).reduce((l,[c,u])=>I(b({},l),{[c]:u}),{}),i=["platform","agentId","agentName","agentEmail","conversationId"].reduce((l,c)=>(o[c]&&(l[c]=o[c]),l),{});return this.client.post("/api/v2/events",Mt(I(b(b({},s),i),{data:r,name:t})),{version:"v2"})})}getEntities(t){return _(this,null,function*(){return yield this.preflight(),yield this.client.post("/api/v2/entities",{messages:t.filter(r=>r.text)})})}getTemporaryExchangeToken(){return _(this,null,function*(){return(yield this.client.get("/apis/admin/session/exchange-token/")).jwt})}exchangeTokenForAccessCookie(t){return _(this,null,function*(){return this.client.post("/apis/admin/session/jwt/",{jwt:t}).catch(n=>{throw J.warn(`Invalid token '${t}'`),n})})}authenticateWithKey(t,n){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/api-key/",Mt(n),{refreshTokenOn401:!1,headers:{apikey:t}})})}getTextSuggestions(o){return _(this,arguments,function*(t,n={},r){if(yield this.preflight(),r==="sticky-messages")throw new Error("Use getPinnedMessages instead");return(yield this.client.post(`/api/v2/conversations/${t}/recommend/${r}`,Mt(n),{abortLatest:!0})).map(i=>I(b({},$e(i)),{text:i.text||i.url||i.message,source:r,type:r})).filter((i,a,l)=>a===l.findIndex(c=>c.text===i.text))})}isLoggedIn(){return _(this,null,function*(){return yield this.preflight(),this.client.validateToken()})}getAutocompleteSuggestions(t,n){return _(this,null,function*(){return yield this.preflight(),(yield this.client.post(`/api/v2/conversations/${t}/autocomplete`,Mt(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,s,i)=>s===i.findIndex(a=>a.text===o.text))})}getPinnedMessages(t){return _(this,null,function*(){let n=yield this.client.get(`/api/v2/profiles/${t}/pinned-messages`,{abortLatest:!0});return $e(n).map(r=>I(b({},r),{text:r.message,source:"sticky-messages",type:"pinned-message"}))})}getStyleSuggestions(t){return _(this,null,function*(){let n=yield this.client.post("/api/v2/style-suggestions",Mt(t),{abortLatest:!0,version:"v2"});return $e(n)})}search(t){return _(this,null,function*(){let n=yield this.client.post(`/api/v2/profiles/${t.profile}/search`,Mt(t));return $e(n)})}loginWithPassword(t,n){return _(this,null,function*(){yield this.preflight();let r=yield this.client.post("/apis/admin/session/login/",{username:t,password:n},{refreshTokenOn401:!1});return $e(r)})}logout(){return _(this,null,function*(){yield this.preflight(),yield this.client.post("/apis/admin/session/logout/",{},{refreshTokenOn401:!1})})}requestLoginByEmail(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/apis/admin/session/passwordless/request/",{email:t});return $e(n)})}requestPasswordlessToken(){return _(this,null,function*(){let t=yield this.client.get("/apis/admin/session/passwordless/request/");return $e(t.token)})}getCsrfToken(){return _(this,null,function*(){let{token:t}=yield this.client.get("/apis/admin/session/csrf/");return t})}verifyLoginToken(t){return _(this,null,function*(){let n=yield this.client.post("/apis/admin/session/passwordless/login/",{token:t});return $e(n)})}evaluateAssistant(t,n){return _(this,null,function*(){var l,c,u;yield this.preflight();let r=new URLSearchParams;n!=null&&n.externalConversationId&&r.append("external_conversation_id",n.externalConversationId);let o=n!=null&&n.threadId?`/api/v2/assistants/${t}/threads/${n==null?void 0:n.threadId}/evaluate?${r.toString()}`:`/api/v2/assistants/${t}/evaluate?${r.toString()}`,s=f=>Mt(f),i=(l=n==null?void 0:n.transcript)==null?void 0:l.map(f=>{var d;return b({source:f.source,text:f.text},(d=f.attachments)!=null&&d.length?{attachments:f.attachments.map(s)}:{})}),a=yield this.client.post(o,b({input:(c=n==null?void 0:n.input)!=null?c:{},conversation:i},(u=n==null?void 0:n.attachments)!=null&&u.length?{attachments:n.attachments.map(s)}:{}));return $e(a)})}createAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n}=t,r=yield this.client.post(`/apis/admin/assistants/${n}/threads/`,{});return $e(r)})}postMessageToAssistantThread(t){return _(this,null,function*(){yield this.preflight();let{assistantCode:n,threadId:r,message:o}=t,s=yield this.client.post(`/apis/admin/assistants/${n}/threads/${r}/messages/`,{content:o,role:"user"});return $e(s)})}translateMessages(t){return _(this,null,function*(){yield this.preflight();let n=yield this.client.post("/api/v2/translate",Mt(t));return $e(n)})}handleDeepdeskVersionHeaders(t){t.headers.forEach((n,r)=>{let o=r.toLowerCase(),s=o.match(hw);if(!n||!s)return;let i=s[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&J.warn(`Overwritten Version header ${o}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};_i.exchangeTokenPromise=null;var _o=_i;var og=class{constructor(t){this.options=t;this.socket=null;this.maxReconnectAttempts=5;this.reconnectInterval=25e3;this.cleanupCallbacks=[];var n,r;this.socket,this.eventListeners=new Map,this.url=t.url,this.maxReconnectAttempts=(n=t.maxReconnectAttempts)!=null?n:this.maxReconnectAttempts,this.reconnectInterval=(r=t.reconnectInterval)!=null?r:this.reconnectInterval,this.shouldReconnect=t.shouldReconnect}connect(){let t=()=>this.cleanup();window.addEventListener("beforeunload",t),this.cleanupCallbacks.push(()=>window.removeEventListener("beforeunload",t)),this.reconnect()}setupListeners(){this.socket&&(this.socket.onmessage=t=>{var n;try{let r=$e(JSON.parse(t.data));r.event&&this.eventListeners.has(r.event)&&((n=this.eventListeners.get(r.event))==null||n.forEach(o=>o(r.data)))}catch(r){console.error("Error parsing WebSocket message:",r)}},this.socket.onclose=t=>{console.log("WebSocket connection closed:",t),setTimeout(()=>{this.reconnect()},this.reconnectInterval)},this.socket.onerror=t=>{console.error("WebSocket error:",t)})}reconnect(){var t,n;if(this.maxReconnectAttempts<=0){console.error("Max reconnect attempts reached, closing WebSocket connection."),(t=this.socket)==null||t.close();return}if(!this.shouldReconnect()){console.error("Should not reconnect, closing WebSocket connection."),(n=this.socket)==null||n.close();return}this.socket&&(this.socket.onmessage=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.close()),this.socket=new WebSocket(this.url),this.setupListeners(),this.maxReconnectAttempts--}send(t,n){if(!this.socket){console.error("WebSocket connection is not open.");return}this.socket.send(JSON.stringify({event:t,data:n}))}on(t,n){this.eventListeners.has(t)||this.eventListeners.set(t,[]);let r=this.eventListeners.get(t);r&&!r.includes(n)&&r.push(n)}close(){var t;(t=this.socket)==null||t.close()}cleanup(){this.close(),this.cleanupCallbacks.forEach(t=>t()),this.cleanupCallbacks=[]}};var a_={startTime:null,stopTime:null},l_=e=>e.handlingTime,c_=Re({name:"handlingTime",initialState:a_,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(ut,()=>a_)}}),{handlingTimeStart:u_,handlingTimeStop:sg,handlingTimeReset:d_}=c_.actions,f_=c_.reducer;var p_=(e={})=>{let t=b({onAuthError:$i(!1)},e);return n=>r=>o=>("error"in o&&o.error.message==="Unauthorized"&&n.dispatch(t.onAuthError),r(o))};var m_=(e={})=>{let t,n=!0,r=b({getStyleSuggestions:Ci,debounce:500},e);return o=>s=>i=>{var p;let a=o.getState().input.text,l=s(i),c=o.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((p=c.conversation.current)==null?void 0:p.id)||!u)return l;let{text:d}=c.input;return d===a&&!n||(clearTimeout(t),d==="")||(t=setTimeout(()=>{n=!1,o.dispatch(r.getStyleSuggestions({text:d}))},e.debounce)),l}};function Oz(e,t){return e.text===t.text&&e.selection.start===t.selection.start&&e.selection.end===t.selection.end&&e.suggestionTextStart===t.suggestionTextStart}var g_=(e={})=>{let t=b({getTextSuggestions:wr,getAutocompleteSuggestions:du,debounce:200,check:jr},e),n;return r=>o=>s=>{var y;let{input:i}=r.getState(),a=o(s),l=r.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:u}=l.settings,f=(y=l.conversation.current)==null?void 0:y.id,d=s.type===Rm.toString();if(!f||!c&&!u)return a;let{input:p}=l;return Oz(p,i)&&!d||(clearTimeout(n),!t.check(l))||(n=setTimeout(()=>{let S=Ls(l);S===""?r.dispatch(t.getTextSuggestions("default")):r.dispatch(t.getAutocompleteSuggestions(S))},d?0:t.debounce)),a}};var h_=Ci.fulfilled.toString();function Lz(e,t){let n=new Set([...t.keywordMatches.map(o=>o.keyword)]),r=[];return n.forEach(o=>{let s=e.keywordMatches.filter(l=>l.keyword===o),i=t.keywordMatches.filter(l=>l.keyword===o),a=i.length-s.length;a<=0||r.push(...i.slice(0,a))}),r}var y_=e=>t=>n=>r=>{var c;if(r.type!==h_){n(r);return}let o=t.getState().styleSuggestions.list;n(r);let s=t.getState(),i=s.styleSuggestions.list,a=(c=s.conversation)==null?void 0:c.current;if(o===i)return;let l=Lz(o,i);r.type===h_&&l.length>0&&e.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,data:{keywordMatches:l}})};var Nz=sd({assistants:$E,auth:Ab,conversation:Nb,contentTypes:VP,passwordlessToken:AI,entities:hA,handlingTime:f_,info:rE,input:Gb,settings:KE,profile:GP,search:cE,styleSuggestions:JA,ui:UA,textSuggestions:kA});function v_(e){return hb({reducer:Nz,middleware:t=>{var r;let n=t({thunk:{extraArgument:{dynamicThunkObject:e.dynamicThunkObject,deepdeskAPI:e.deepdeskAPI}},serializableCheck:!1}).concat(p_()).concat(g_({debounce:200})).concat(m_({debounce:500})).concat(y_(e.deepdeskAPI));return((r=e.middleware)!=null?r:[]).reduce((o,s)=>o.concat(s),n)},preloadedState:e.preloadedState})}function S_(e,t,n){if(t==="")return null;let r=new RegExp(`\\b${Um(t)}\\b`,"gi"),o,s=null;for(;(o=r.exec(e))!==null&&!(o.index>n);)s={start:o.index,end:o.index+o[0].length};return s}var Dz=e=>{var t,n;return(n=(t=e==null?void 0:e.type)==null?void 0:t.toLowerCase())!=null?n:"unknown"},Fz=e=>t=>n=>r=>{var l,c,u,f,d,p;let o=t.getState(),s=Vs("inlineSuggestions")(o),i=Vs("autoSelectSuggestion")(o)||s;switch(r.type){case $i.toString():{!r.payload&&e.emit("logout",void 0);break}case Td.fulfilled.toString():{e.emit("logout",void 0);break}case xr.fulfilled.toString():r.payload.length>0&&e.sendEvent("entities found",{conversationId:(l=o.conversation.current)==null?void 0:l.id,data:{entities:r.payload}});break;case Fs.toString():e.logSendMessage(r.payload);break;case rf.toString():e.emit("call-to-action",{cue:r.payload});break;case fn.fulfilled.toString():if(!r.isBroadcasted){let{externalConversationId:h,currentExternalIdAtRequest:y}=(c=r.payload)!=null?c:{};(!h||!y||h===y)&&e.broadcast(xh,r,!1)}break;case fn.rejected.toString():break;default:break}let a=n(r);switch(r.type){case Fs.toString():e.handleAfterSendMessage(r.payload);break;case pu.toString():e.onUpdateShowTabHint(r.payload);break;case sg.toString():e.logHandlingTime();break;case Gi.toString():e.broadcast(zd,r);break;case Ds.toString():e.broadcast(zd,r);break;case of.toString():t.dispatch(Ds({source:"assistant",assistantCode:r.payload.code}));break;case"analytics/logEvent/fulfilled":{let h=o.assistants.cues.find(y=>y.code===r.meta.arg.data.assistantCode);e.emit("event",I(b({},r.meta.arg),{cue:h}));break}case kn.toString():{let{start:h,end:y}=o.input.selection;e.emit("select-suggestion",I(b({type:Dz(r.payload.suggestion)},r.payload),{replace:r.payload.replace==="selection"?{start:h,end:y}:{start:0,end:y}})),s&&t.dispatch(Ho([]));break}case ZA.toString():{let{keyword:h,suggestion:y,eventMetrics:S}=r.payload,{text:g,selection:m}=o.input,v=S_(g,h,(u=m==null?void 0:m.end)!=null?u:g.length);if(!v)break;e.emit("select-suggestion",{text:y,type:"style",replace:v,suggestion:{text:y,source:"style"},eventMetrics:S});break}case _d.toString():e.emit("select-image",r.payload),e.sendEvent("Image attached",{conversationId:(f=o.conversation.current)==null?void 0:f.id,data:{path:r.payload.suggestion.image,title:r.payload.suggestion.title}});break;case Ho.toString():{i&&r.payload.length>0&&t.dispatch(Md(0));break}case fn.fulfilled.toString():{let{evaluationId:h,output:y,externalConversationId:S}=r.payload,g=r.meta.arg.assistantCode;if(e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:h,assistantCode:g,assistantOutput:HE(y),externalConversationId:S,evaluationStatus:"success"}}),!r.meta.arg.skipState){let m=t.getState().assistants.cues;e.emit("cues",m)}break}case fn.rejected.toString():{let h=r.meta.arg.assistantCode,y=(p=r.meta.arg.externalConversationId)!=null?p:(d=t.getState().conversation.current)==null?void 0:d.externalId;e.emit("event",{name:"Assistant evaluation completed",data:{evaluationId:"",assistantCode:h,assistantOutput:"",externalConversationId:y,evaluationStatus:"failed"}});break}default:break}return a},x_=Fz;function ex(e){return e.toISOString().replace("T"," ").replace("Z","")}var zz=(e,t)=>t.version,w_=un([qi,Pr,l_,zz],(e,t,n,r)=>{if(!t)return J.warn("No conversationId for handling time metrics"),null;let{startTime:o,stopTime:s}=n;return!o||!s?(J.warn("No startTime and stopTime for handling time metrics"),null):{conversationId:t,clientVersion:r,agentId:e==null?void 0:e.agentId,agentName:e==null?void 0:e.agentName,agentEmail:e==null?void 0:e.agentEmail,timeStart:ex(o),timeStop:ex(s)}});function b_(e,t){let{text:n,metrics:{numPaste:r,pastes:o,textSuggestions:s}}=e.input,i=n.length;return{source:"agent",clientVersion:t.version,pastes:o,lenTextTotal:i,numPastes:r,suggestions:s}}var ku=class extends Error{};function Hz(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}var ig=class{constructor(){this.queues={}}push(t,n){let r=()=>{let s=this.queues[t][1];s?(this.queues[t]=[s.promise,null],s.resolve()):delete this.queues[t]};if(!this.queues[t]){let s=n().finally(r);return this.queues[t]=[s,null],s}this.queues[t][1]&&this.queues[t][1].reject(new ku("Queued async function is outdated"));let o=Hz();return this.queues[t][1]=o,o.promise.then(()=>n().finally(r))}};function tx(e,t){var s;let n=e.closest(t);if(n)return n;let r=e.getRootNode().host;if(r instanceof HTMLElement)return tx(r,t);let o=(s=e.ownerDocument.defaultView)==null?void 0:s.frameElement;return o?tx(o,t):null}function nx(e,t){return tx(e,t)}var Bz={accepted:"onConversationAcceptedAssistants","new-message":"onConversationNewMessageAssistants",ended:"onConversationEndedAssistants"},E_=(e,t)=>{var o,s,i;if(!((i=(s=(o=e.uiConfig)==null?void 0:o.widget)==null?void 0:s.types.find(a=>a.type==="cues"))==null?void 0:i.isActive))return J.warn("Triggered a conversation assistant, but cues are not configured in widget."),[];let r=e[Bz[t]];return r&&r.length>0?r.map(a=>a.code):(J.warn(`No assistant set in profile for conversation event "${t}"`),[])};function C_(e){return typeof e=="object"&&e!==null&&"name"in e&&"message"in e}function Uz(e){return typeof e=="object"&&e!==null&&"tagName"in e}function ag(e){return Uz(e)&&(ki(e)||Hm(e))}var k_,qr=new Map,Vz=["bottom","height","left","right","top","width"],T_=(e,t)=>!e&&!t?!1:e&&!t||!e&&t?!0:Vz.some(n=>e[n]!==t[n]);function R_(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,...R_(t)]:[]}function P_(e,t){return!e||!t?null:I(b({},e),{top:e.top+t.top,left:e.left+t.left})}var lg=!1,A_=()=>{lg=!0;let e=[];if(qr.forEach((t,n)=>{if(!n.isConnected){t.rect=null,e.push(t),qr.delete(n);return}let r=n.getBoundingClientRect();T_(r,t.rect)&&(t.rect=r,e.push(t))}),e.forEach(t=>{let n=t.parentRects?t.parentRects.reduce(P_,t.rect):t.rect;T_(n,t.totalRect)&&t.callbacks.forEach(r=>r(n)),t.totalRect=n}),qr.size===0){lg=!1;return}k_=window.requestAnimationFrame(A_)};function rx(e,t){let n=R_(e),r=[],o=n.map((s,i)=>rx(s,a=>{r[i]=a;let l=qr.get(e);if(!l)return;let c=r.reduce(P_,l.rect);l.callbacks.forEach(u=>u(c))}));return{observe(s=!0){if(o.forEach(i=>i.observe(!1)),qr.has(e)){let i=qr.get(e);i.callbacks.push(t),i.rect&&t(i.rect)}else qr.set(e,{rect:void 0,callbacks:[t],parentRects:r});s&&!lg&&A_()},unobserve(){o.forEach(i=>i.unobserve());let s=qr.get(e);if(s){let i=s.callbacks.indexOf(t);i>=0&&s.callbacks.splice(i,1),s.callbacks.length||qr.delete(e),qr.size||(cancelAnimationFrame(k_),lg=!1)}}}}var I_,Yr=new Map,__=()=>{Yr.forEach((e,t)=>{if(!t.isConnected){Yr.delete(t);return}let{clientHeight:n,scrollHeight:r}=t,o=r>n;e.visible!==o&&(e.visible=o,e.callbacks.forEach(s=>s(e.visible)))}),Yr.size!==0&&(I_=window.requestAnimationFrame(__))};function M_(e,t){return{observe(){let n=Yr.size===0;Yr.has(e)?Yr.get(e).callbacks.push(t):Yr.set(e,{visible:void 0,callbacks:[t]}),n&&__()},unobserve(){let n=Yr.get(e);if(n){let r=n.callbacks.indexOf(t);r>=0&&n.callbacks.splice(r,1),n.callbacks.length||Yr.delete(e),Yr.size||cancelAnimationFrame(I_)}}}}var ox=["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 sx(e,t,n){return n.forEach(r=>{t.style[r]=e[r]})}function ol(e){return Number.parseFloat(e)}function cg(e){return Math.round(e*1e6)}function O_(e){return e/1e6}function ix(e,t,n){if(e.boxSizing==="content-box")return;let{clientWidth:r}=t,o=ol(e.width),s=ol(e.borderLeftWidth),i=ol(e.borderRightWidth),a=ol(e.paddingRight),l=O_(cg(o)-cg(s)-cg(i)),c=O_(cg(r));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function Ru(e,t={}){var u,f;let n=t.overlayContainer||document.createElement("div");n.style.display="none",n.style.position=(u=t.position)!=null?u:"fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",mi(n);let r=window.getComputedStyle(e),o=!0,s=()=>{n.scrollTop=e.scrollTop};sx(r,n,ox),ix(r,e,n),t.mirrorOverflow&&(n.style.overflow="hidden",e.addEventListener("scroll",s));let i=M_(e,()=>{sx(r,n,ox),ix(r,e,n),s(),setTimeout(s,0)}),a,l=!0,c=rx(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(sx(r,n,ox),ix(r,e,n),s(),t.placement==="below"&&n.classList.add("below"),n.style.top=`${d.top}px`,n.style.left=`${d.left}px`,t.closestScrollElement&&t.closestScrollElement!==e){let p=t.closestScrollElement.getBoundingClientRect(),h=window.getComputedStyle(t.closestScrollElement),y=ol(h.borderTopWidth),S=ol(h.borderBottomWidth),g=p.top+y-d.top,m=d.top+d.height+-(p.top+p.height-S);n.style.clipPath=`inset(${g}px 0px ${m}px 0px)`}o&&(n.style.display="block",t.onShow&&t.onShow(),o=!1)});return t.appendTo?t.appendTo.appendChild(n):(f=e.parentElement)==null||f.appendChild(n),c.observe(),i.observe(),[n,()=>{e.removeEventListener("scroll",s),c.unobserve(),i.unobserve(),n.remove()}]}function Wz(e){return e.offsetParent!==null}function L_(e){if(!Wz(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 ug(e,t,n=100){let r=L_(e);t({isVisible:r});let o=setInterval(()=>{let s=L_(e);s!==r&&(r=s,t({isVisible:r}))},n);return()=>{clearTimeout(o)}}var N_=(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){J.warn("[Deepdesk] SessionStorage is blocked by browser")}}});var ke=E(A());var D_=N_("showTabHint",!0),sl=class sl{constructor({deepdeskUrl:t,version:n=sl.version||"unknown",locale:r="en-US",token:o,fetch:s,productName:i,createCustomChannel:a,websocketClient:l=og}){this.inputMediator=null;this.eventListeners={};this.unmountHandlers=[];this.disposeHandlers=[];this.inlineSuggestions=null;this.aboveSuggestions=null;this.belowSuggestions=null;this.floatingMenu=null;this.widgetElement=null;this.widgetRoot=null;this.nicknameDialogUnsubscribe=null;this.nicknameDialogFailed=!1;this.dynamicThunkObject={};this.queues=new ig;this.isMounted=!1;this.shouldRender=!0;this.loadProfileConfigPromise=null;let c=t.replace(/\/api$/,"");this.deepdeskApi=new _o(c,{token:o,fetch:s}),this.version=n,this.instanceId=sl.count++;let u={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[x_({broadcast:(h,y,S)=>{this.broadcastEvents.send(h,y,S)},emit:(h,y)=>this.emit(h,y),handleAfterSendMessage:h=>this.handleAfterSendMessage(h),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:h=>this.logSendMessage(h),onUpdateShowTabHint:h=>D_.update(h),sendEvent:(h,y)=>this.deepdeskApi.sendEvent(h,y)})]};this.store=v_(u),this.broadcastEvents=new o_({debug:!0,deepdeskUrl:c,eventMap:uE(this.store),createCustomChannel:a}),this.disposeHandlers.push(()=>{this.broadcastEvents.cleanup()}),this.ws=new l({url:`${c}/api/v2/me/realtime`.replace("https","wss"),reconnectInterval:25e3,shouldReconnect:()=>_(this,null,function*(){var h;return(h=kt(this.state))!=null?h:!1})}),this.whenLoggedIn(()=>this.ws.connect()),this.store.dispatch(pu(D_.value())),this.store.dispatch(sf({locale:r,adminUrl:c,productName:i}));let f=[],d=h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(WE(h))};this.hasConversation()?y():f.push(y)};this.ws.on("assistants::direct_response",d),this.ws.on("assistants::user_notification",d),this.ws.on("assistants::response_chunk",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(VE(h))};this.hasConversation()?y():f.push(y)}),this.ws.on("assistants::suggest_as_reply",h=>{if(!h.conversationId)return;let y=()=>{this.conversationId()===h.conversationId&&this.store.dispatch(Gi([{text:h.payload.message,type:"text",source:"assistant",assistantCode:h.code,sourceLabel:h.name}]))};this.hasConversation()?y():f.push(y)});let p=this.whenConversationLoaded(()=>{var h;this.broadcastEvents.setExternalId((h=this.state.conversation.current)==null?void 0:h.externalId),f.forEach(y=>y()),f.length=0});this.disposeHandlers.push(()=>{this.ws.cleanup(),f.length=0,p()})}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){var t;return(t=Ns(this.state)[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}externalId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.externalId}shouldAbort(){return this.state.conversation.isSupported===!1?(J.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(J.warn("Profile has not been loaded (yet)"),!0):(J.warn("No conversation loaded (yet)"),!0)}whenLoggedIn(t){if(kt(this.state))t();else{let n=this.subscribe(kt,r=>{r&&t()});this.disposeHandlers.push(()=>{n()})}}login(){return this.store.dispatch($i(null)),this.store.dispatch(Jr()),new Promise(t=>{this.whenLoggedIn(()=>t())})}isLoggedIn(){return _(this,null,function*(){return(yield this.store.dispatch(Jr())).payload})}isConversationSupported(t,n){return _(this,null,function*(){return(yield this.store.dispatch(ph({externalId:t,options:n}))).payload})}createConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(Pd(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}getConversationByExternalId(t,n){return _(this,null,function*(){return this.hasConversation()&&this.externalId()!==t&&this.resetConversation(),(yield this.store.dispatch(Ad({externalId:t,options:n}))).payload})}upsertConversation(t){return _(this,null,function*(){var r;return this.hasConversation()&&this.externalId()!==t.externalId&&this.resetConversation(),(yield this.store.dispatch(mh(I(b({},t),{metadata:(r=t.metadata)!=null?r:{}})))).payload})}postMessages(t){return _(this,null,function*(){yield this.store.dispatch(gh(t))})}updateConversation(t){return _(this,null,function*(){return(yield this.store.dispatch(Id(t))).payload})}resetConversation(){this.store.dispatch(ut()),this.loadProfileConfigPromise=null,this.dynamicThunkObject.conversationQuery=null}configure(t){this.store.dispatch(sf(t))}setVisitorInfo(t){this.store.dispatch(Jb(t))}setCustomData(t){this.store.dispatch(eE(t))}setAgentInfo(t,n){return _(this,null,function*(){var o;yield this.store.dispatch(El(b(b({},t),n))),(o=this.state.info.agentInfo)!=null&&o.agentNickname||this.broadcastEvents.send(Fd,{showNicknameDialog:!0})})}setAgentSettings(t){return _(this,null,function*(){yield this.store.dispatch(yh(t))})}getAgentSettings(){return _(this,null,function*(){return(yield this.store.dispatch(vh())).payload})}refresh(){return _(this,null,function*(){if(this.shouldAbort())return Promise.resolve();let t=[];return t.push(this.refreshTextSuggestions()),t.push(this.refreshWidgetSuggestions()),Promise.all(t).then(()=>{})})}syncInputMediator(){this.inputMediator&&this.store.dispatch(Od({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()}))}notifyExternalSuggestion(t){this.store.dispatch(kn(t))}evaluateAssistant(t,n){return _(this,null,function*(){var u;let{input:r={},attachments:o=[],transcript:s,showCuesInWidget:i=!0,includeMetadata:a,externalConversationId:l}=n||{},c=yield this.store.dispatch(fn({assistantCode:t,attachments:o,transcript:s,includeMetadata:a,input:r,externalConversationId:l,skipState:!i}));if(c.error)throw new Error(`Assistant evaluation failed: ${(u=c.payload)!=null?u:c.error.message}`);return c.payload.output})}evaluateConversationAssistant(t,n){return _(this,null,function*(){var u,f,p;yield this.loadProfileConfig();let r=this.state.profile.data;if(!r&&((u=this.state.conversation.current)!=null&&u.profileCode)&&(yield this.loadProfileConfig(),r=this.state.profile.data),!r){J.warn("Can't evaluate assistant when profile is not loaded yet.");return}let o=E_(r,t),s=(f=n==null?void 0:n.showCuesInWidget)!=null?f:!0,d=n!=null?n:{},{showCuesInWidget:i}=d,a=ie(d,["showCuesInWidget"]),l=(p=n==null?void 0:n.externalConversationId)!=null?p:this.hasConversation()?this.externalId():"",c=yield Promise.all(o.map(h=>this.queues.push(h,()=>_(this,null,function*(){var S,g;let y=yield this.store.dispatch(fn(b(I(b({assistantCode:h,includeMetadata:!0},a),{skipState:!s}),n!=null&&n.attachments&&(n==null?void 0:n.attachments.length)>0?{attachments:n==null?void 0:n.attachments}:{})));if(y.error)throw new Error(`Assistant evaluation failed: ${(S=y.payload)!=null?S:y.error.message}`);return{assistantCode:h,evaluationId:y.payload.evaluationId,output:y.payload.output,externalConversationId:(g=y.payload.externalConversationId)!=null?g:l}})).catch(y=>{if(y instanceof ku)return J.warn(`Queued assistant "${h}" was outdated and dropped`),null;throw y})));if(!s)return c.filter(h=>h!==null)})}handleKeyDown(t){let{overlayCollapsed:n,openOverlayWhenTyping:r}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:s,selection:i}=this.state.input,{inlineSuggestions:a,autoSelectSuggestion:l,showTextSuggestions:c,suggestionsPlacement:u}=this.settings,f=a||l,d=u==="inline"||u==="below"?"below":"above",p=o.length>0;if(this.store.dispatch(Bb(hh(t))),!jr(this.state)||t.key!=="Tab"&&!c)return;let h=()=>{n||!p||i&&(t.shiftKey||(this.store.dispatch(Wb()),t.preventDefault()))},y=()=>{n||!p||f&&s<=0||i&&(t.shiftKey||(this.store.dispatch($b()),t.preventDefault()))};switch(t.key){case"ArrowUp":d==="below"?y():h();break;case"ArrowDown":{d==="below"?h():y();break}case"Escape":{n||(this.store.dispatch(Md(-1)),this.store.dispatch(vs({collapse:!0})),this.store.dispatch(HA(!0)),t.preventDefault());break}case"Tab":{t.preventDefault();let S=Ki(this.state);if(!S)return;this.store.dispatch(pu(!1)),this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"tab"},replace:"until-selection-end"}));break}case" ":{if(f||this.state.input.selectedSuggestionIndex===-1)return;let S=Ki(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"space"},replace:"until-selection-end"}));break}case"Enter":{if(f||t.shiftKey||this.state.input.selectedSuggestionIndex===-1)return;let S=Ki(this.state);if(!S)return;this.store.dispatch(kn({text:S.text,suggestion:S,eventMetrics:{inputType:"enter"},replace:"until-selection-end"})),t.preventDefault();break}default:}n&&r&&this.store.dispatch(vs({collapse:!1}))}handleAfterSendMessage(t){this.emit("send-message",t),this.store.dispatch(Ho([]))}handlingTimeStart(){this.state.handlingTime.startTime||(J.info("Start handling time"),this.store.dispatch(u_()))}handlingTimeStop(){this.state.handlingTime.startTime&&(J.info("Stop handling time"),this.store.dispatch(sg()))}logSendMessage(t){let n=b_(this.state,{version:this.version});n&&(t&&(Object.assign(n,{text:t}),Object.assign(n,{lenTextTotal:t.length})),this.deepdeskApi.sendEvent("Send Message",{conversationId:this.conversationId(),data:n}),this.emit("send-message-event",n))}logHandlingTime(){let t=w_(this.state,{version:this.version});t&&(this.deepdeskApi.sendEvent("Handling Time",{conversationId:this.conversationId(),data:t}),this.store.dispatch(d_()))}notifySubmit(t={}){var n;this.shouldAbort()||(this.store.dispatch(Fs((n=t.text)!=null?n:this.state.input.text)),this.store.dispatch(Kb()))}emit(t,n){let r=this.eventListeners[t];r&&r.forEach(o=>{try{o(n)}catch(s){J.warn(`The following error occurred in deepdeskSDK.on('${t}', handler)`),J.error(s)}})}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}setPlatformVariables(t){this.store.dispatch(tE(t))}whenConversationLoaded(t){let n=s=>{var i;return(i=s.conversation.current)==null?void 0:i.id},r=()=>this.loadProfileConfig().then(()=>t());return n(this.state)&&r(),this.subscribe(n,s=>{s&&r()})}overlayContainerFactory(t,n,r,o){let[s,i]=Ru(n,r);return s.setAttribute("translate","no"),s.dataset.testid=t,o&&s.classList.add(o),[s,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 s=(a=t.ownerDocument.defaultView)==null?void 0:a.frameElement,i=s?s.ownerDocument.defaultView:null;if(s&&(i===window||(i==null?void 0:i.parent)===window)){let[l,c]=Ru(s,{appendTo:document.body,onMoveStart:()=>{o.style.display="none"}});l.dataset.testid=n,l.style.zIndex="2",l.appendChild(r),this.unmountHandlers.push(()=>{c()})}else document.body.appendChild(r);return o}createContainer(t,n=document.body){let r=window.getComputedStyle(n),o=document.createElement("div");return mi(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),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),J.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()?(J.info(`Restored metrics for ${this.conversationId()}`),this.store.dispatch(jb(r.metrics))):J.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(!ag(t))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let d=n,{customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i,inputMediator:a}=d,l=ie(d,["customStyles","closestScrollSelector","floatingMenuParent","appendOverlayTo","inputMediator"]),c={customStyles:r,closestScrollSelector:o,floatingMenuParent:s,appendOverlayTo:i};this.configure(l),this.settings.automaticHandlingTime&&this.setupHandlingTime(t),mi(t),this.inputMediator=a||(ki(t)?new Ai(t):new Pi(t)),this.inputMediator.on("change",({plainText:p,rawHTML:h,suggestionTextStart:y})=>{this.store.dispatch(Od({text:p,html:h,suggestionTextStart:y}))}),this.inputMediator.on("keyup",p=>{this.store.dispatch(Ub(hh(p)))}),this.inputMediator.on("keydown",p=>{this.handleKeyDown(p)}),this.inputMediator.on("paste",({pastedText:p,selectionText:h})=>{this.store.dispatch(Vb({text:p,selectionText:h}))}),this.inputMediator.on("cut",({selectionText:p})=>{this.store.dispatch(Hb(p))});let u;this.inputMediator.on("selection",p=>{clearTimeout(u),p===null?u=setTimeout(()=>{p!==null&&this.store.dispatch(Ld(p))},500):this.store.dispatch(Ld(p))}),this.unmountHandlers.push(()=>{clearTimeout(u)}),this.inputMediator.on("disabled",()=>{var p;(p=this.inputMediator)==null||p.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{this.settings.detectSubmit&&this.notifySubmit()}),this.inputMediator.on("blur",()=>{this.store.dispatch(Im(!1))}),this.inputMediator.on("focus",()=>{this.store.dispatch(Im(!0))}),this.renderSuggestions(t,c),this.subscribe(Vs("inlineSuggestions"),()=>{this.renderSuggestions(t,c)}),this.subscribe(Vs("suggestionsPlacement"),()=>{this.renderSuggestions(t,c)});let f=this.renderOverlays(n);this.unmountHandlers.push(()=>{f.unmount()}),this.store.dispatch(Od({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),suggestionTextStart:this.inputMediator.getSuggestionTextStart()})),this.store.dispatch(Ld(this.inputMediator.getSelection())),this.store.dispatch(Im(this.inputMediator.isFocused)),this.unmountHandlers.push(()=>{this.state.input.text!==""&&this.storeMetrics()}),this.whenConversationLoaded(()=>{this.restoreMetrics(),this.syncInputMediator(),this.refreshTextSuggestions(),this.promptForNickname()}),this.isMounted=!0}promptForNickname(t){if(this.nicknameDialogUnsubscribe||this.nicknameDialogFailed)return;let n=this.createContainer("nickname-dialog",document.body);document.body.appendChild(n);let r=(0,Mo.createRoot)(n),o=null,s=a=>{o=a,i()},i=()=>{r==null||r.render((0,ke.jsx)(To,{store:this.store,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(nI,{id:"deepdesk-nickname-dialog",error:o,onSave:a=>_(this,null,function*(){try{yield this.store.dispatch(Qb({agentNickname:a})).unwrap(),console.log("setAgentNickname",a),this.broadcastEvents.send(Fd,{showNicknameDialog:!1}),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe()}catch(l){J.error("Error setting agent nickname",l),s("error"),this.nicknameDialogFailed=!0}})})})}))};i(),this.nicknameDialogUnsubscribe=()=>{r.unmount(),n.remove(),this.nicknameDialogUnsubscribe=null}}subscribe(t,n){let r=t(this.store.getState());return this.store.subscribe(()=>{let o=t(this.store.getState());o!==r&&(r=o,n(r))})}unmount(){var t,n,r,o,s;(t=this.inlineSuggestions)==null||t.unmount(),(n=this.aboveSuggestions)==null||n.unmount(),(r=this.belowSuggestions)==null||r.unmount(),(o=this.floatingMenu)==null||o.unmount(),this.unmountHandlers.forEach(i=>i()),this.unmountHandlers=[],(s=this.inputMediator)==null||s.dispose(),this.nicknameDialogUnsubscribe&&this.nicknameDialogUnsubscribe(),this.isMounted=!1}dispose(){this.unmount(),this.unmountWidget(),this.disposeHandlers.forEach(t=>t()),this.disposeHandlers=[],this.off()}renderSuggestions(t,n){var r,o,s,i;(r=this.floatingMenu)==null||r.unmount(),(o=this.inlineSuggestions)==null||o.unmount(),(s=this.aboveSuggestions)==null||s.unmount(),(i=this.belowSuggestions)==null||i.unmount(),this.settings.floatingMenu&&(this.floatingMenu=this.renderFloatingMenu(t,n)),this.settings.inlineSuggestions||this.settings.suggestionsPlacement==="inline"?this.inlineSuggestions=this.renderInlineSuggestions(t,n):this.settings.suggestionsPlacement==="below"?this.belowSuggestions=this.renderAboveOrBelowSuggestions(t,n,"below"):this.aboveSuggestions=this.renderAboveOrBelowSuggestions(t,n,"above")}renderInlineSuggestions(t,n){let{customStyles:r}=n,o=this.createInlineContainer(t,"deepdesk-caret"),s=(0,Mo.createRoot)(o);s.render((0,ke.jsx)(To,{store:this.store,customStyles:r,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(eI,{})})}));let i=a=>{a?(o.style.display="block",o.style.top=`${a.top}px`,o.style.left=`${a.left}px`):o.style.display="none"};return this.inputMediator.on("caretposition",i),{unmount:()=>{var a;(a=this.inputMediator)==null||a.off("caretposition",i),s.unmount(),o.remove()}}}renderAboveOrBelowSuggestions(t,n,r){let{customStyles:o,closestScrollSelector:s,appendOverlayTo:i}=n,a=s&&nx(t,s)||void 0,[l,c]=this.overlayContainerFactory("deepdesk-tab-completion",a||t,{appendTo:i,closestScrollElement:a,mirrorOverflow:!0,onRemove:()=>this.unmount()},o==null?void 0:o.rootNode),[u,f]=this.overlayContainerFactory("deepdesk-suggestions-overlay",a||t,{appendTo:i,placement:r},o==null?void 0:o.suggestionsRootNode),d=(0,Mo.createRoot)(l);d.render((0,ke.jsx)(To,{store:this.store,customStyles:o,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(kI,{inputElement:t})})}));let p=(0,Mo.createRoot)(u);return p.render((0,ke.jsx)(To,{store:this.store,customStyles:o,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(dI,{onLogIn:()=>this.loginViaPopup().catch(h=>J.warn(h.message))})})})),{unmount(){d.unmount(),p.unmount(),c(),f()}}}renderFloatingMenu(t,n){let{customStyles:r,closestScrollSelector:o,appendOverlayTo:s,floatingMenuParent:i}=n,a=o&&nx(t,o)||void 0,[l,c]=this.overlayContainerFactory("floating-menu",a||t,{appendTo:i!=null?i:s},r==null?void 0:r.floatingMenuParent),u=(0,Mo.createRoot)(l);return u.render((0,ke.jsx)(To,{store:this.store,customStyles:r,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(FA,{onLogIn:()=>this.loginViaPopup().catch(f=>J.warn(f.message))})})})),{unmount(){u.unmount(),c()}}}renderOverlays(t){let{customStyles:n}=t,r=this.createContainer("deepdesk-overlays"),o=(0,Mo.createRoot)(r);return o.render((0,ke.jsx)(To,{store:this.store,customStyles:n,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(MA,{})})})),{unmount(){o.unmount(),r.remove()}}}renderWidget(t,n={}){if(this.widgetElement&&J.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:r,showImages:o,isEmbedded:s,signInViaPopup:i,ssoUrl:a,openAdminFeedback:l}=n;this.widgetElement=t,this.configure({showImages:o,isEmbedded:s,signInViaPopup:i});let c;if(a)try{c={url:new URL(a,this.settings.adminUrl).toString()}}catch(u){J.warn(`Invalid ssoUrl '${a}' passed to renderWidget`)}this.widgetRoot=(0,Mo.createRoot)(t),this.widgetRoot.render((0,ke.jsx)(To,{store:this.store,customStyles:r,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(ZI,{assistantOptions:n.assistantOptions,knowledgeAssistOptions:n.knowledgeAssist,openAdminFeedback:l,onLogIn:()=>this.loginViaPopup(c).catch(u=>J.warn(u.message))})})}))}unmountWidget(){var t,n;(n=(t=this.widgetRoot)==null?void 0:t.unmount)==null||n.call(t),this.widgetRoot=null,this.widgetElement=null}renderKnowledgeAssistantWidget(t,n,r={}){let{customStyles:o,initialQuestion:s}=r,i=(0,Mo.createRoot)(n);return i.render((0,ke.jsx)(To,{store:this.store,customStyles:o,children:(0,ke.jsx)(to,{broadcastEvents:this.broadcastEvents,children:(0,ke.jsx)(YS,{children:(0,ke.jsxs)(lm,{assistantCode:t,initialQuestion:s,evaluateKnowledgeAssistFn:Ul,children:[(0,ke.jsx)(Bi,{children:(0,ke.jsx)(um,{title:r.title,emptyState:r.emptyState})}),(0,ke.jsx)(qS,{children:(0,ke.jsx)(cm,{})})]})})})})),{unmount(){i.unmount()}}}setupHandlingTime(t){let n=ug(t,({isVisible:r})=>{r?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(t){C_(t)&&t.message==="Unauthorized"&&this.login()}loadProfileConfig(){var t;return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(t=this.state.conversation.current)!=null&&t.profileCode?(this.loadProfileConfigPromise=Promise.resolve().then(()=>_(this,null,function*(){yield this.store.dispatch(Xc()).unwrap();let n=fs(this.state);n&&this.store.dispatch(sf({showSearch:n.search,showImageSearch:n.imageSearch,showEntitiesCommand:n.entitiesCommand,showSummaryCommand:!!n.summarizerAssistantNew,showKnowledgeSearch:!!n.knowledgeAssistantNew||!!n.knowledgeAssistant,recommendTextSuggestions:n.recommendTextSuggestions}))})).finally(()=>{fs(this.state)||(this.loadProfileConfigPromise=null)}),this.loadProfileConfigPromise):Promise.resolve()}loginViaPopup(t){return _(this,null,function*(){return new Promise((n,r)=>{this.store.dispatch(kd());let o=new MessageChannel,s=o.port1,i=this.settings.adminUrl,a=new URL(t!=null&&t.url?t==null?void 0:t.url:`${i}/platform/sso/`);a.searchParams.append("redirect","/sdk/popup/close.html");let l=!1,c=()=>{u&&!u.closed&&u.close(),window.removeEventListener("message",f),clearInterval(d)};s.onmessage=p=>_(this,null,function*(){var h,y;if((h=p.data)!=null&&h.jwt)try{yield this.deepdeskApi.exchangeTokenForAccessCookie((y=p.data)==null?void 0:y.jwt),yield this.isLoggedIn(),this.broadcastEvents.send(Tl),l=!0,o.port1.close(),n()}catch(S){console.error(S),r(S)}finally{l=!0,c()}});let u=window.open(a.toString(),"deepdesk-login","scrollbars=no,left=100,top=150,width=500,height=500");if(u===null){r(new Error("Popup blocked by browser"));return}let f=p=>_(this,null,function*(){var h;if(!(p.origin!==a.origin||p.source!==u))switch((h=p.data)==null?void 0:h.type){case"deepdesk-popup-request-origin":{try{let y=JSON.stringify({type:"deepdesk-popup-parent-origin"});u.postMessage(y,a.origin)}catch(y){J.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-loaded":{try{let y=JSON.stringify({type:"deepdesk-popup-create-channel"});u.postMessage(y,a.origin,[o.port2])}catch(y){J.error("Error posting message to popup",y),r(y)}break}case"deepdesk-popup-error":{if(c(),p.data.message==="Platform account url mismatch"){let y="Please contact your administrator: The page that opened the popup is not a trusted origin.";J.warn(y),this.store.dispatch(uh(y)),r(new Error(y));return}if(p.data.message==="Timeout"){let y="Please contact your administrator: Popup timed out. Check if the account's platform.url or account.url is configured correctly.";J.warn(y),this.store.dispatch(uh(y)),r(new Error(y));return}r(new Error(p.data.message));break}}});window.addEventListener("message",f);let d=setInterval(()=>{u&&!u.closed||(c(),l||r(new Error("Popup closed by user")))},200);this.disposeHandlers.push(c)})})}translateMessages(t){return this.deepdeskApi.translateMessages(t)}refreshTextSuggestions(){return _(this,null,function*(){this.isMounted&&(yield this.store.dispatch(Rm()))})}refreshWidgetSuggestions(){return _(this,null,function*(){if(!this.widgetRoot)return;let{uiConfig:t}=this.state.profile.data;if(!t.widget)return;let n=Qc(this.state);try{n.forEach(({type:r})=>{switch(r){case"entities":this.store.dispatch(xr());break;case"pinned-messages":case"sticky-messages":break;default:td.includes(r)||this.store.dispatch(wr(r))}})}catch(r){this.handleError(r)}})}};sl.version="19.6.2-beta.0",sl.count=0;var Pu=sl;function $z(e){return _(this,null,function*(){var o,s,i;let n=yield((o=e.fetch)!=null?o:window.fetch)(e.url),r=yield n.blob();return new File([r],e.name,{type:(i=(s=e.mimeType)!=null?s:n.headers.get("Content-Type"))!=null?i:"image/jpeg"})})}function F_(e,t){return _(this,null,function*(){let n=yield $z(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}})}function z_(e,t,n){return _(this,null,function*(){yield new _o(e).authenticateWithKey(t,n)})}function H_(e){return e.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}function B_(r,o){return _(this,arguments,function*(e,t,n={}){var f,d;let{value:s}=e,{start:i,end:a}=(f=n.replace)!=null?f:{start:0,end:s.length},l=`${s.slice(0,i)}${t}${s.slice(a)}`,c=(d=n.selectionAfter)!=null?d:{start:i+t.length,end:i+t.length},u=()=>{if(n.setValue)return n.setValue(l);e.value=l};return Promise.resolve(u()).then(()=>{e.selectionStart=c.start,e.selectionEnd=c.end,e.blur(),e.focus()})})}function U_(r,o){return _(this,arguments,function*(e,t,n={}){let s=n.replace?Cs(e,n.replace.start,n.replace.end):nl(e),i,a=()=>{if(n.setRange)return n.setRange(s.cloneRange());s.deleteContents(),i=document.createElement("span"),s.insertNode(i),n.insertBRs!==!1?t.split(`
|
|
84
84
|
`).reverse().forEach((l,c)=>{c>0&&s.insertNode(document.createElement("br")),s.insertNode(document.createTextNode(l))}):s.insertNode(document.createTextNode(t))};return Promise.resolve(a()).then(()=>{try{if(n.selectionAfter!==!1){e.focus();let l=n.selectionAfter?Cs(e,n.selectionAfter.start,n.selectionAfter.end):(s.collapse(!1),s),c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)}if(!i)return;i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}function jz(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 Kz(e){let t=document.createDocumentFragment();return e.split(`
|
|
85
85
|
`).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br"));let o={index:0},s=0;for(;o=n.slice(s).match(/(\[([^\]]+)])\(([^)]+)\)/);){let i=document.createElement("a");i.href=o[3],i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer"),i.appendChild(document.createTextNode(o[2])),t.appendChild(document.createTextNode(n.slice(s,s+o.index))),t.appendChild(i),s=s+o.index+o[0].length}t.appendChild(document.createTextNode(n.slice(s)))}),t}function V_(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):V_(n,t)}function W_(o,s){return _(this,arguments,function*(e,t,{isBlock:n,isHTML:r}={}){let i;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,c=l.getSelection();if((!c||c.rangeCount===0)&&(e.focus(),c=l.getSelection()),!c||c.rangeCount===0)return;let u=c.getRangeAt(0);if(!u)return;i=document.createElement("span"),u.insertNode(i);let f=r?jz(t):Kz(t);n?V_(u.startContainer,f):(u.insertNode(f),u.collapse(!1))};return Promise.resolve(a()).then(()=>{if(e.dispatchEvent(new InputEvent("input",{inputType:"insertText",data:t,bubbles:!0,cancelable:!0})),e.focus(),!!i)try{i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"})}finally{i&&i.remove()}})})}return fM(Gz);})();
|
|
86
86
|
/*! Bundled license information:
|