@freeday-ai/webchat 2025.10.2-7.14.34.3193 → 2025.10.2-7.14.54.1411
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/webchat.iife.js +1 -1
- package/dist/webchat.mjs +1 -0
- package/package.json +1 -1
package/dist/webchat.iife.js
CHANGED
|
@@ -327,4 +327,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
327
327
|
`))+1))}const s="#".repeat(o),u=n.enter("headingAtx"),A=n.enter("phrasing");i.move(s+" ");let p=n.containerPhrasing(a,{before:"# ",after:`
|
|
328
328
|
`,...i.current()});return/^[\t ]/.test(p)&&(p=Bi(p.charCodeAt(0))+p.slice(1)),p=p?s+" "+p:s,n.options.closeAtx&&(p+=" "+s),A(),u(),p}u21.peek=qu2;function u21(a){return a.value||""}function qu2(){return"<"}h21.peek=Wu2;function h21(a,t,n,l){const o=Yh0(n),i=o==='"'?"Quote":"Apostrophe",s=n.enter("image");let u=n.enter("label");const A=n.createTracker(l);let p=A.move("![");return p+=A.move(n.safe(a.alt,{before:p,after:"]",...A.current()})),p+=A.move("]("),u(),!a.url&&a.title||/[\0- \u007F]/.test(a.url)?(u=n.enter("destinationLiteral"),p+=A.move("<"),p+=A.move(n.safe(a.url,{before:p,after:">",...A.current()})),p+=A.move(">")):(u=n.enter("destinationRaw"),p+=A.move(n.safe(a.url,{before:p,after:a.title?" ":")",...A.current()}))),u(),a.title&&(u=n.enter(`title${i}`),p+=A.move(" "+o),p+=A.move(n.safe(a.title,{before:p,after:o,...A.current()})),p+=A.move(o),u()),p+=A.move(")"),s(),p}function Wu2(){return"!"}d21.peek=Gu2;function d21(a,t,n,l){const o=a.referenceType,i=n.enter("imageReference");let s=n.enter("label");const u=n.createTracker(l);let A=u.move("![");const p=n.safe(a.alt,{before:A,after:"]",...u.current()});A+=u.move(p+"]["),s();const g=n.stack;n.stack=[],s=n.enter("reference");const V=n.safe(n.associationId(a),{before:A,after:"]",...u.current()});return s(),n.stack=g,i(),o==="full"||!p||p!==V?A+=u.move(V+"]"):o==="shortcut"?A=A.slice(0,-1):A+=u.move("]"),A}function Gu2(){return"!"}A21.peek=Yu2;function A21(a,t,n){let l=a.value||"",o="`",i=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++i<n.unsafe.length;){const s=n.unsafe[i],u=n.compilePattern(s);let A;if(s.atBreak)for(;A=u.exec(l);){let p=A.index;l.charCodeAt(p)===10&&l.charCodeAt(p-1)===13&&p--,l=l.slice(0,p)+" "+l.slice(A.index+1)}}return o+l+o}function Yu2(){return"`"}function p21(a,t){const n=lh0(a);return!!(!t.options.resourceLink&&a.url&&!a.title&&a.children&&a.children.length===1&&a.children[0].type==="text"&&(n===a.url||"mailto:"+n===a.url)&&/^[a-z][a-z+.-]+:/i.test(a.url)&&!/[\0- <>\u007F]/.test(a.url))}f21.peek=Ku2;function f21(a,t,n,l){const o=Yh0(n),i=o==='"'?"Quote":"Apostrophe",s=n.createTracker(l);let u,A;if(p21(a,n)){const g=n.stack;n.stack=[],u=n.enter("autolink");let V=s.move("<");return V+=s.move(n.containerPhrasing(a,{before:V,after:">",...s.current()})),V+=s.move(">"),u(),n.stack=g,V}u=n.enter("link"),A=n.enter("label");let p=s.move("[");return p+=s.move(n.containerPhrasing(a,{before:p,after:"](",...s.current()})),p+=s.move("]("),A(),!a.url&&a.title||/[\0- \u007F]/.test(a.url)?(A=n.enter("destinationLiteral"),p+=s.move("<"),p+=s.move(n.safe(a.url,{before:p,after:">",...s.current()})),p+=s.move(">")):(A=n.enter("destinationRaw"),p+=s.move(n.safe(a.url,{before:p,after:a.title?" ":")",...s.current()}))),A(),a.title&&(A=n.enter(`title${i}`),p+=s.move(" "+o),p+=s.move(n.safe(a.title,{before:p,after:o,...s.current()})),p+=s.move(o),A()),p+=s.move(")"),u(),p}function Ku2(a,t,n){return p21(a,n)?"<":"["}Z21.peek=Xu2;function Z21(a,t,n,l){const o=a.referenceType,i=n.enter("linkReference");let s=n.enter("label");const u=n.createTracker(l);let A=u.move("[");const p=n.containerPhrasing(a,{before:A,after:"]",...u.current()});A+=u.move(p+"]["),s();const g=n.stack;n.stack=[],s=n.enter("reference");const V=n.safe(n.associationId(a),{before:A,after:"]",...u.current()});return s(),n.stack=g,i(),o==="full"||!p||p!==V?A+=u.move(V+"]"):o==="shortcut"?A=A.slice(0,-1):A+=u.move("]"),A}function Xu2(){return"["}function Kh0(a){const t=a.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Qu2(a){const t=Kh0(a),n=a.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ju2(a){const t=a.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function H21(a){const t=a.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function eh2(a,t,n,l){const o=n.enter("list"),i=n.bulletCurrent;let s=a.ordered?Ju2(n):Kh0(n);const u=a.ordered?s==="."?")":".":Qu2(n);let A=t&&n.bulletLastUsed?s===n.bulletLastUsed:!1;if(!a.ordered){const g=a.children?a.children[0]:void 0;if((s==="*"||s==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(A=!0),H21(n)===s&&g){let V=-1;for(;++V<a.children.length;){const v=a.children[V];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){A=!0;break}}}}A&&(s=u),n.bulletCurrent=s;const p=n.containerFlow(a,l);return n.bulletLastUsed=s,n.bulletCurrent=i,o(),p}function ah2(a){const t=a.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function th2(a,t,n,l){const o=ah2(n);let i=n.bulletCurrent||Kh0(n);t&&t.type==="list"&&t.ordered&&(i=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(a))+i);let s=i.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||a.spread))&&(s=Math.ceil(s/4)*4);const u=n.createTracker(l);u.move(i+" ".repeat(s-i.length)),u.shift(s);const A=n.enter("listItem"),p=n.indentLines(n.containerFlow(a,u.current()),g);return A(),p;function g(V,v,L){return v?(L?"":" ".repeat(s))+V:(L?i:i+" ".repeat(s-i.length))+V}}function nh2(a,t,n,l){const o=n.enter("paragraph"),i=n.enter("phrasing"),s=n.containerPhrasing(a,l);return i(),o(),s}const lh2=Ud(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function rh2(a,t,n,l){return(a.children.some(function(s){return lh2(s)})?n.containerPhrasing:n.containerFlow).call(n,a,l)}function oh2(a){const t=a.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}g21.peek=ch2;function g21(a,t,n,l){const o=oh2(n),i=n.enter("strong"),s=n.createTracker(l),u=s.move(o+o);let A=s.move(n.containerPhrasing(a,{after:o,before:u,...s.current()}));const p=A.charCodeAt(0),g=nA(l.before.charCodeAt(l.before.length-1),p,o);g.inside&&(A=Bi(p)+A.slice(1));const V=A.charCodeAt(A.length-1),v=nA(l.after.charCodeAt(0),V,o);v.inside&&(A=A.slice(0,-1)+Bi(V));const L=s.move(o+o);return i(),n.attentionEncodeSurroundingInfo={after:v.outside,before:g.outside},u+A+L}function ch2(a,t,n){return n.options.strong||"*"}function ih2(a,t,n,l){return n.safe(a.value,l)}function sh2(a){const t=a.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function mh2(a,t,n){const l=(H21(n)+(n.options.ruleSpaces?" ":"")).repeat(sh2(n));return n.options.ruleSpaces?l.slice(0,-1):l}const E21={blockquote:Tu2,break:s21,code:Pu2,definition:_u2,emphasis:m21,hardBreak:s21,heading:ju2,html:u21,image:h21,imageReference:d21,inlineCode:A21,link:f21,linkReference:Z21,list:eh2,listItem:th2,paragraph:nh2,root:rh2,strong:g21,text:ih2,thematicBreak:mh2};function uh2(){return{enter:{table:hh2,tableData:V21,tableHeader:V21,tableRow:Ah2},exit:{codeText:ph2,table:dh2,tableData:Xh0,tableHeader:Xh0,tableRow:Xh0}}}function hh2(a){const t=a._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},a),this.data.inTable=!0}function dh2(a){this.exit(a),this.data.inTable=void 0}function Ah2(a){this.enter({type:"tableRow",children:[]},a)}function Xh0(a){this.exit(a)}function V21(a){this.enter({type:"tableCell",children:[]},a)}function ph2(a){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,fh2));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(a)}function fh2(a,t){return t==="|"?t:a}function Zh2(a){const t=a||{},n=t.tableCellPadding,l=t.tablePipeAlign,o=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
329
329
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:s,tableCell:A,tableRow:u}};function s(L,C,I,T){return p(g(L,I,T),L.align)}function u(L,C,I,T){const N=V(L,I,T),D=p([N]);return D.slice(0,D.indexOf(`
|
|
330
|
-
`))}function A(L,C,I,T){const N=I.enter("tableCell"),D=I.enter("phrasing"),B=I.containerPhrasing(L,{...T,before:i,after:i});return D(),N(),B}function p(L,C){return Su2(L,{align:C,alignDelimiters:l,padding:n,stringLength:o})}function g(L,C,I){const T=L.children;let N=-1;const D=[],B=C.enter("table");for(;++N<T.length;)D[N]=V(T[N],C,I);return B(),D}function V(L,C,I){const T=L.children;let N=-1;const D=[],B=C.enter("tableRow");for(;++N<T.length;)D[N]=A(T[N],L,C,I);return B(),D}function v(L,C,I){let T=E21.inlineCode(L,C,I);return I.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function Hh2(){return{exit:{taskListCheckValueChecked:M21,taskListCheckValueUnchecked:M21,paragraph:Eh2}}}function gh2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Vh2}}}function M21(a){const t=this.stack[this.stack.length-2];t.type,t.checked=a.type==="taskListCheckValueChecked"}function Eh2(a){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const l=n.children[0];if(l&&l.type==="text"){const o=t.children;let i=-1,s;for(;++i<o.length;){const u=o[i];if(u.type==="paragraph"){s=u;break}}s===n&&(l.value=l.value.slice(1),l.value.length===0?n.children.shift():n.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,n.position.start=Object.assign({},l.position.start)))}}this.exit(a)}function Vh2(a,t,n,l){const o=a.children[0],i=typeof a.checked=="boolean"&&o&&o.type==="paragraph",s="["+(a.checked?"x":" ")+"] ",u=n.createTracker(l);i&&u.move(s);let A=E21.listItem(a,t,n,{...l,...u.current()});return i&&(A=A.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),A;function p(g){return g+s}}function Mh2(){return[eu2(),Vu2(),wu2(),uh2(),Hh2()]}function vh2(a){return{extensions:[au2(),Mu2(a),yu2(),Zh2(a),gh2()]}}const Lh2={tokenize:Ih2,partial:!0},v21={tokenize:Sh2,partial:!0},L21={tokenize:Rh2,partial:!0},w21={tokenize:Th2,partial:!0},wh2={tokenize:xh2,partial:!0},y21={name:"wwwAutolink",tokenize:Ch2,previous:C21},F21={name:"protocolAutolink",tokenize:bh2,previous:b21},z3={name:"emailAutolink",tokenize:Fh2,previous:I21},Bt={};function yh2(){return{text:Bt}}let jr=48;for(;jr<123;)Bt[jr]=z3,jr++,jr===58?jr=65:jr===91&&(jr=97);Bt[43]=z3,Bt[45]=z3,Bt[46]=z3,Bt[95]=z3,Bt[72]=[z3,F21],Bt[104]=[z3,F21],Bt[87]=[z3,y21],Bt[119]=[z3,y21];function Fh2(a,t,n){const l=this;let o,i;return s;function s(V){return!Qh0(V)||!I21.call(l,l.previous)||Jh0(l.events)?n(V):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),u(V))}function u(V){return Qh0(V)?(a.consume(V),u):V===64?(a.consume(V),A):n(V)}function A(V){return V===46?a.check(wh2,g,p)(V):V===45||V===95||be(V)?(i=!0,a.consume(V),A):g(V)}function p(V){return a.consume(V),o=!0,A}function g(V){return i&&o&&Qe(l.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),t(V)):n(V)}}function Ch2(a,t,n){const l=this;return o;function o(s){return s!==87&&s!==119||!C21.call(l,l.previous)||Jh0(l.events)?n(s):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(Lh2,a.attempt(v21,a.attempt(L21,i),n),n)(s))}function i(s){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),t(s)}}function bh2(a,t,n){const l=this;let o="",i=!1;return s;function s(V){return(V===72||V===104)&&b21.call(l,l.previous)&&!Jh0(l.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),o+=String.fromCodePoint(V),a.consume(V),u):n(V)}function u(V){if(Qe(V)&&o.length<5)return o+=String.fromCodePoint(V),a.consume(V),u;if(V===58){const v=o.toLowerCase();if(v==="http"||v==="https")return a.consume(V),A}return n(V)}function A(V){return V===47?(a.consume(V),i?p:(i=!0,A)):n(V)}function p(V){return V===null||Nd(V)||M8(V)||Or(V)||$d(V)?n(V):a.attempt(v21,a.attempt(L21,g),n)(V)}function g(V){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),t(V)}}function Ih2(a,t,n){let l=0;return o;function o(s){return(s===87||s===119)&&l<3?(l++,a.consume(s),o):s===46&&l===3?(a.consume(s),i):n(s)}function i(s){return s===null?n(s):t(s)}}function Sh2(a,t,n){let l,o,i;return s;function s(p){return p===46||p===95?a.check(w21,A,u)(p):p===null||M8(p)||Or(p)||p!==45&&$d(p)?A(p):(i=!0,a.consume(p),s)}function u(p){return p===95?l=!0:(o=l,l=void 0),a.consume(p),s}function A(p){return o||l||!i?n(p):t(p)}}function Rh2(a,t){let n=0,l=0;return o;function o(s){return s===40?(n++,a.consume(s),o):s===41&&l<n?i(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?a.check(w21,t,i)(s):s===null||M8(s)||Or(s)?t(s):(a.consume(s),o)}function i(s){return s===41&&l++,a.consume(s),o}}function Th2(a,t,n){return l;function l(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(a.consume(u),l):u===38?(a.consume(u),i):u===93?(a.consume(u),o):u===60||u===null||M8(u)||Or(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||M8(u)||Or(u)?t(u):l(u)}function i(u){return Qe(u)?s(u):n(u)}function s(u){return u===59?(a.consume(u),l):Qe(u)?(a.consume(u),s):n(u)}}function xh2(a,t,n){return l;function l(i){return a.consume(i),o}function o(i){return be(i)?n(i):t(i)}}function C21(a){return a===null||a===40||a===42||a===95||a===91||a===93||a===126||M8(a)}function b21(a){return!Qe(a)}function I21(a){return!(a===47||Qh0(a))}function Qh0(a){return a===43||a===45||a===46||a===95||be(a)}function Jh0(a){let t=a.length,n=!1;for(;t--;){const l=a[t][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){n=!0;break}if(l._gfmAutolinkLiteralWalkedInto){n=!1;break}}return a.length>0&&!n&&(a[a.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Nh2={tokenize:Uh2,partial:!0};function $h2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Oh2,continuation:{tokenize:_h2},exit:Bh2}},text:{91:{name:"gfmFootnoteCall",tokenize:Ph2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kh2,resolveTo:Dh2}}}}function kh2(a,t,n){const l=this;let o=l.events.length;const i=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;o--;){const A=l.events[o][1];if(A.type==="labelImage"){s=A;break}if(A.type==="gfmFootnoteCall"||A.type==="labelLink"||A.type==="label"||A.type==="image"||A.type==="link")break}return u;function u(A){if(!s||!s._balanced)return n(A);const p=Wa(l.sliceSerialize({start:s.end,end:l.now()}));return p.codePointAt(0)!==94||!i.includes(p.slice(1))?n(A):(a.enter("gfmFootnoteCallLabelMarker"),a.consume(A),a.exit("gfmFootnoteCallLabelMarker"),t(A))}}function Dh2(a,t){let n=a.length;for(;n--;)if(a[n][1].type==="labelImage"&&a[n][0]==="enter"){a[n][1];break}a[n+1][1].type="data",a[n+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},a[n+3][1].start),end:Object.assign({},a[a.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},a[n+3][1].end),end:Object.assign({},a[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},a[a.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},u=[a[n+1],a[n+2],["enter",l,t],a[n+3],a[n+4],["enter",o,t],["exit",o,t],["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t],a[a.length-2],a[a.length-1],["exit",l,t]];return a.splice(n,a.length-n+1,...u),a}function Ph2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i=0,s;return u;function u(V){return a.enter("gfmFootnoteCall"),a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),A}function A(V){return V!==94?n(V):(a.enter("gfmFootnoteCallMarker"),a.consume(V),a.exit("gfmFootnoteCallMarker"),a.enter("gfmFootnoteCallString"),a.enter("chunkString").contentType="string",p)}function p(V){if(i>999||V===93&&!s||V===null||V===91||M8(V))return n(V);if(V===93){a.exit("chunkString");const v=a.exit("gfmFootnoteCallString");return o.includes(Wa(l.sliceSerialize(v)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),t):n(V)}return M8(V)||(s=!0),i++,a.consume(V),V===92?g:p}function g(V){return V===91||V===92||V===93?(a.consume(V),i++,p):p(V)}}function Oh2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i,s=0,u;return A;function A(C){return a.enter("gfmFootnoteDefinition")._container=!0,a.enter("gfmFootnoteDefinitionLabel"),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(C),a.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(C){return C===94?(a.enter("gfmFootnoteDefinitionMarker"),a.consume(C),a.exit("gfmFootnoteDefinitionMarker"),a.enter("gfmFootnoteDefinitionLabelString"),a.enter("chunkString").contentType="string",g):n(C)}function g(C){if(s>999||C===93&&!u||C===null||C===91||M8(C))return n(C);if(C===93){a.exit("chunkString");const I=a.exit("gfmFootnoteDefinitionLabelString");return i=Wa(l.sliceSerialize(I)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(C),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),v}return M8(C)||(u=!0),s++,a.consume(C),C===92?V:g}function V(C){return C===91||C===92||C===93?(a.consume(C),s++,g):g(C)}function v(C){return C===58?(a.enter("definitionMarker"),a.consume(C),a.exit("definitionMarker"),o.includes(i)||o.push(i),W2(a,L,"gfmFootnoteDefinitionWhitespace")):n(C)}function L(C){return t(C)}}function _h2(a,t,n){return a.check(Li,t,a.attempt(Nh2,t,n))}function Bh2(a){a.exit("gfmFootnoteDefinition")}function Uh2(a,t,n){const l=this;return W2(a,o,"gfmFootnoteDefinitionIndent",5);function o(i){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(i):n(i)}}function zh2(a){let n=(a||{}).singleTilde;const l={name:"strikethrough",tokenize:i,resolveAll:o};return n==null&&(n=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(s,u){let A=-1;for(;++A<s.length;)if(s[A][0]==="enter"&&s[A][1].type==="strikethroughSequenceTemporary"&&s[A][1]._close){let p=A;for(;p--;)if(s[p][0]==="exit"&&s[p][1].type==="strikethroughSequenceTemporary"&&s[p][1]._open&&s[A][1].end.offset-s[A][1].start.offset===s[p][1].end.offset-s[p][1].start.offset){s[A][1].type="strikethroughSequence",s[p][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},s[p][1].start),end:Object.assign({},s[A][1].end)},V={type:"strikethroughText",start:Object.assign({},s[p][1].end),end:Object.assign({},s[A][1].start)},v=[["enter",g,u],["enter",s[p][1],u],["exit",s[p][1],u],["enter",V,u]],L=u.parser.constructs.insideSpan.null;L&&j4(v,v.length,0,kd(L,s.slice(p+1,A),u)),j4(v,v.length,0,[["exit",V,u],["enter",s[A][1],u],["exit",s[A][1],u],["exit",g,u]]),j4(s,p-1,A-p+3,v),A=p+v.length-2;break}}for(A=-1;++A<s.length;)s[A][1].type==="strikethroughSequenceTemporary"&&(s[A][1].type="data");return s}function i(s,u,A){const p=this.previous,g=this.events;let V=0;return v;function v(C){return p===126&&g[g.length-1][1].type!=="characterEscape"?A(C):(s.enter("strikethroughSequenceTemporary"),L(C))}function L(C){const I=t9(p);if(C===126)return V>1?A(C):(s.consume(C),V++,L);if(V<2&&!n)return A(C);const T=s.exit("strikethroughSequenceTemporary"),N=t9(C);return T._open=!N||N===2&&!!I,T._close=!I||I===2&&!!N,u(C)}}}class jh2{constructor(){this.map=[]}add(t,n,l){qh2(this,t,n,l)}consume(t){if(this.map.sort(function(i,s){return i[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const l=[];for(;n>0;)n-=1,l.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];l.push(t.slice()),t.length=0;let o=l.pop();for(;o;){for(const i of o)t.push(i);o=l.pop()}this.map.length=0}}function qh2(a,t,n,l){let o=0;if(!(n===0&&l.length===0)){for(;o<a.map.length;){if(a.map[o][0]===t){a.map[o][1]+=n,a.map[o][2].push(...l);return}o+=1}a.map.push([t,n,l])}}function Wh2(a,t){let n=!1;const l=[];for(;t<a.length;){const o=a[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(a[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(a[t-1][1].type==="tableDelimiterMarker"){const i=l.length-1;l[i]=l[i]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return l}function Gh2(){return{flow:{null:{name:"table",tokenize:Yh2,resolveAll:Kh2}}}}function Yh2(a,t,n){const l=this;let o=0,i=0,s;return u;function u(Q){let f0=l.events.length-1;for(;f0>-1;){const s0=l.events[f0][1].type;if(s0==="lineEnding"||s0==="linePrefix")f0--;else break}const t0=f0>-1?l.events[f0][1].type:null,c0=t0==="tableHead"||t0==="tableRow"?z:A;return c0===z&&l.parser.lazy[l.now().line]?n(Q):c0(Q)}function A(Q){return a.enter("tableHead"),a.enter("tableRow"),p(Q)}function p(Q){return Q===124||(s=!0,i+=1),g(Q)}function g(Q){return Q===null?n(Q):Q1(Q)?i>1?(i=0,l.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(Q),a.exit("lineEnding"),L):n(Q):_2(Q)?W2(a,g,"whitespace")(Q):(i+=1,s&&(s=!1,o+=1),Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),s=!0,g):(a.enter("data"),V(Q)))}function V(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),g(Q)):(a.consume(Q),Q===92?v:V)}function v(Q){return Q===92||Q===124?(a.consume(Q),V):V(Q)}function L(Q){return l.interrupt=!1,l.parser.lazy[l.now().line]?n(Q):(a.enter("tableDelimiterRow"),s=!1,_2(Q)?W2(a,C,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):C(Q))}function C(Q){return Q===45||Q===58?T(Q):Q===124?(s=!0,a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),I):G(Q)}function I(Q){return _2(Q)?W2(a,T,"whitespace")(Q):T(Q)}function T(Q){return Q===58?(i+=1,s=!0,a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),N):Q===45?(i+=1,N(Q)):Q===null||Q1(Q)?q(Q):G(Q)}function N(Q){return Q===45?(a.enter("tableDelimiterFiller"),D(Q)):G(Q)}function D(Q){return Q===45?(a.consume(Q),D):Q===58?(s=!0,a.exit("tableDelimiterFiller"),a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),B):(a.exit("tableDelimiterFiller"),B(Q))}function B(Q){return _2(Q)?W2(a,q,"whitespace")(Q):q(Q)}function q(Q){return Q===124?C(Q):Q===null||Q1(Q)?!s||o!==i?G(Q):(a.exit("tableDelimiterRow"),a.exit("tableHead"),t(Q)):G(Q)}function G(Q){return n(Q)}function z(Q){return a.enter("tableRow"),X(Q)}function X(Q){return Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),X):Q===null||Q1(Q)?(a.exit("tableRow"),t(Q)):_2(Q)?W2(a,X,"whitespace")(Q):(a.enter("data"),J(Q))}function J(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),X(Q)):(a.consume(Q),Q===92?Z0:J)}function Z0(Q){return Q===92||Q===124?(a.consume(Q),J):J(Q)}}function Kh2(a,t){let n=-1,l=!0,o=0,i=[0,0,0,0],s=[0,0,0,0],u=!1,A=0,p,g,V;const v=new jh2;for(;++n<a.length;){const L=a[n],C=L[1];L[0]==="enter"?C.type==="tableHead"?(u=!1,A!==0&&(S21(v,t,A,p,g),g=void 0,A=0),p={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(n,0,[["enter",p,t]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(l=!0,V=void 0,i=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,g={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(n,0,[["enter",g,t]])),o=C.type==="tableDelimiterRow"?2:g?3:1):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(l=!1,s[2]===0&&(i[1]!==0&&(s[0]=s[1],V=lA(v,t,i,o,void 0,V),i=[0,0,0,0]),s[2]=n)):C.type==="tableCellDivider"&&(l?l=!1:(i[1]!==0&&(s[0]=s[1],V=lA(v,t,i,o,void 0,V)),i=s,s=[i[1],n,0,0])):C.type==="tableHead"?(u=!0,A=n):C.type==="tableRow"||C.type==="tableDelimiterRow"?(A=n,i[1]!==0?(s[0]=s[1],V=lA(v,t,i,o,n,V)):s[1]!==0&&(V=lA(v,t,s,o,n,V)),o=0):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(s[3]=n)}for(A!==0&&S21(v,t,A,p,g),v.consume(t.events),n=-1;++n<t.events.length;){const L=t.events[n];L[0]==="enter"&&L[1].type==="table"&&(L[1]._align=Wh2(t.events,n))}return a}function lA(a,t,n,l,o,i){const s=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(i.end=Object.assign({},h9(t.events,n[0])),a.add(n[0],0,[["exit",i,t]]));const A=h9(t.events,n[1]);if(i={type:s,start:Object.assign({},A),end:Object.assign({},A)},a.add(n[1],0,[["enter",i,t]]),n[2]!==0){const p=h9(t.events,n[2]),g=h9(t.events,n[3]),V={type:u,start:Object.assign({},p),end:Object.assign({},g)};if(a.add(n[2],0,[["enter",V,t]]),l!==2){const v=t.events[n[2]],L=t.events[n[3]];if(v[1].end=Object.assign({},L[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const C=n[2]+1,I=n[3]-n[2]-1;a.add(C,I,[])}}a.add(n[3]+1,0,[["exit",V,t]])}return o!==void 0&&(i.end=Object.assign({},h9(t.events,o)),a.add(o,0,[["exit",i,t]]),i=void 0),i}function S21(a,t,n,l,o){const i=[],s=h9(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),l.end=Object.assign({},s),i.push(["exit",l,t]),a.add(n+1,0,i)}function h9(a,t){const n=a[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const Xh2={name:"tasklistCheck",tokenize:Jh2};function Qh2(){return{text:{91:Xh2}}}function Jh2(a,t,n){const l=this;return o;function o(A){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?n(A):(a.enter("taskListCheck"),a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),i)}function i(A){return M8(A)?(a.enter("taskListCheckValueUnchecked"),a.consume(A),a.exit("taskListCheckValueUnchecked"),s):A===88||A===120?(a.enter("taskListCheckValueChecked"),a.consume(A),a.exit("taskListCheckValueChecked"),s):n(A)}function s(A){return A===93?(a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),a.exit("taskListCheck"),u):n(A)}function u(A){return Q1(A)?t(A):_2(A)?a.check({tokenize:ed2},t,n)(A):n(A)}}function ed2(a,t,n){return W2(a,l,"whitespace");function l(o){return o===null?n(o):t(o)}}function ad2(a){return KJ0([yh2(),$h2(),zh2(a),Gh2(),Qh2()])}const td2={};function nd2(a){const t=this,n=a||td2,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),i=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(ad2(n)),i.push(Mh2()),s.push(vh2(n))}const ld2=$u0("relative flex w-full flex-col gap-3",{variants:{variant:{received:"items-start",sent:"items-end"},layout:{user:"",ai:"w-full max-w-full items-center"},isLastInGroup:{true:"",false:""}},defaultVariants:{variant:"received",layout:"user"}}),ed0=e.forwardRef(({settings:a,className:t,variant:n,isLastInGroup:l,isFirstInGroup:o,sentAt:i,layout:s,children:u,testId:A="",userName:p,...g},V)=>_.jsxs("div",{"data-testid":n=="received"?`chat-message-${A} incoming-message-${A}`:`chat-message-${A} outgoing-message-${A}`,children:[n&&o&&od2({variant:n,settings:a,userName:p}),_.jsx("div",{className:q2(ld2({variant:n,layout:s,isLastInGroup:l,className:t}),a!=null&&a.avatar?"pl-6":""),ref:V,...g,children:u})]}));ed0.displayName="Message";const rd2=$u0("p-4",{variants:{variant:{received:"message-received",sent:"message-send"},layout:{default:"",ai:"message-ai"},isLoading:{true:"animate-pulse bg-gray-200",false:""}},defaultVariants:{variant:"received",layout:"default"}}),Ui=e.forwardRef(({className:a,variant:t,layout:n,isLoading:l=!1,children:o,...i},s)=>_.jsx("div",{className:q2(rd2({variant:t,layout:n,isLoading:l,className:a}),"overflow-x-auto break-words"),ref:s,...i,children:o}));Ui.displayName="MessageBubble";const od2=({variant:a,settings:t,userName:n})=>a!=="received"?null:_.jsxs("div",{className:"mb-1 flex items-center justify-start space-x-1",children:[(t==null?void 0:t.avatar)&&_.jsx("img",{width:48,height:48,className:"mt-1 h-5 w-5 rounded-full",src:t.avatar,alt:"Avatar"}),n&&_.jsx("span",{className:"font-brand text-[11.2px] font-bold leading-[16.8px] text-primary",children:n})]}),cd2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(Ui,{variant:t,layout:n,isLoading:l,className:"prose max-w-[95%] break-words prose-a:text-blue-600",children:_.jsx(O01,{rehypePlugins:[a21],remarkPlugins:[nd2],components:{a:id2},className:"",skipHtml:!0,children:a.content})});function id2(a){return _.jsx("a",{href:a.href,target:"_blank",children:a.children})}const R21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));R21.displayName="Card";const T21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("flex flex-col space-y-1.5 p-6",a),...t}));T21.displayName="CardHeader";const x21=e.forwardRef(({className:a,...t},n)=>_.jsx("h3",{ref:n,className:q2("text-2xl font-semibold leading-none tracking-tight",a),...t}));x21.displayName="CardTitle";const N21=e.forwardRef(({className:a,...t},n)=>_.jsx("p",{ref:n,className:q2("text-sm text-muted-foreground",a),...t}));N21.displayName="CardDescription";const $21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("p-6 pt-0",a),...t}));$21.displayName="CardContent";const k21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("flex items-center p-6 pt-0",a),...t}));k21.displayName="CardFooter";const sd2=({block:a})=>{const{t}=Le("common");return a.sources.some(l=>l.document_metadata&&l.document_metadata.card)?_.jsx("div",{className:"flex w-full max-w-full gap-5 overflow-x-auto",children:a.sources.map(l=>_.jsxs(R21,{"data-url":l.source_link,className:"min-w-[200px] max-w-72 overflow-hidden",children:[_.jsx(T21,{className:"h-full max-h-[120px] p-0",children:_.jsx("img",{className:"h-full w-full object-cover transition duration-300 ease-in-out group-hover:scale-105",src:l.document_metadata.card.image,alt:l.document_metadata.card.title})}),_.jsxs($21,{className:"p-4",children:[_.jsx(x21,{className:"text-md line-clamp-1 font-bold",children:l.document_metadata.card.title}),l.document_metadata.card.description&&_.jsx(N21,{className:"line-clamp-2 text-sm",children:l.document_metadata.card.description})]}),_.jsx(k21,{children:_.jsx("a",{href:l.document_metadata.card.url,target:"_blank",children:_.jsx(ua,{variant:"outline",children:l.document_metadata.card.call_to_action_text??t("sourceCallToActionLabel")})})})]},l.id))}):_.jsx(_.Fragment,{})},md2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(Ui,{variant:t,layout:n,isLoading:l,className:"max-w-[95%]",children:_.jsx("img",{src:a.url,alt:a.filename})}),D21={markdown:cd2,text:({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(Ui,{variant:t,layout:n,isLoading:l,className:"prose max-w-[60%]",children:_.jsx("p",{children:a.text})}),button:M0.Fragment,button_group:Gm2,source_group:sd2,image_reference:md2,conversation_rating:M0.Fragment},ud2=a=>a in D21,P21=(a,t,n)=>{const l=D21[a.type];return typeof l<"u"?M0.createElement(l,{key:`block-${a.id}`,variant:t,layout:n,block:a}):(console.warn(`No component found for block type: ${a.type}`),null)};function hd2({message:a,handleActionEvent:t,close:n}){return _.jsxs(Zd,{className:"sm:max-w-[425px]",children:[_.jsxs(wu0,{children:[_.jsx(yu0,{children:"Thank you for your response!"}),_.jsx(MQ0,{children:"Can you tell us what went wrong?"})]}),_.jsx(pd2,{message:a,handleActionEvent:t,close:n})]})}function dd2({message:a,handleActionEvent:t,close:n}){const{t:l}=Le(["common","feedback"]),[o,i]=e.useState(""),[s,u]=e.useState(!1),[A,p]=e.useState(!1),g=V=>{V.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),p(!0),setTimeout(()=>{u(!1),setTimeout(n,1500)},1500)};return _.jsxs(Ed,{className:"min-h-40 overflow-hidden rounded-t-[20px] border-primary bg-primary text-primary-foreground",children:[_.jsx(T7,{children:_.jsx(nl.div,{layoutId:"underline",children:_.jsx(Vd,{className:"",children:A?_.jsx(mJ0,{title:l("feedback:modalSubmittedTitle"),description:l("feedback:modalSubmittedDescription")}):_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("div",{className:"relative w-12"}),_.jsxs("div",{className:"text-center",children:[_.jsx(di,{className:"text-center",children:l("feedback:modalTitle")}),_.jsx(Nu0,{className:"text-primary-foreground/80",children:l("feedback:modalDescription")})]}),_.jsx(xu0,{className:"w-12",asChild:!0,children:_.jsx(ua,{variant:"link",onClick:n,className:"text-right text-primary-foreground",children:_.jsx(Xn,{weight:"regular",size:20})})})]})})})}),A?_.jsx(_.Fragment,{}):_.jsxs(nl.form,{onSubmit:g,className:"mt-auto flex flex-col gap-2 p-4 pt-2",children:[_.jsx(bd,{className:"border border-white text-base text-white shadow-none ring-0 placeholder:text-white focus-visible:ring-0 widget:text-sm",placeholder:l("feedback:modalPlaceholder"),"data-testid":"feedback-form-textarea",value:o,rows:4,disabled:s,onChange:V=>i(V.target.value)}),_.jsx(ua,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:l(s?"sending":"send")})]})]})}const Ad2=({message:a,handleActionEvent:t})=>{const{t:n}=Le("common"),{openModal:l,closeModal:o}=BQ0(),i=ou0("(min-width: 768px)"),{state:s}=we(),u=A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"negative"}),i&&!s.inShadowDom?l(Y7.Dialog,_.jsx(hd2,{message:a,handleActionEvent:t,close:o})):l(Y7.Drawer,_.jsx(dd2,{message:a,handleActionEvent:t,close:o}))};return _.jsxs("div",{className:"flex justify-start space-x-3",children:[_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="positive"?"text-green-500":"text-primary"}`,"data-testid":`thumbs-up thumbs-feedback-sentiment-${a.user_feedback_value==="positive"?a.user_feedback_value:"none"}`,onClick:A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"positive"})},children:[_.jsx(RG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="positive"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsUp")})]}),_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="negative"?"text-red-500":"text-primary"}`,"data-testid":`thumbs-down thumbs-feedback-sentiment-${a.user_feedback_value==="negative"?a.user_feedback_value:"none"}`,onClick:u,children:[_.jsx(SG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="negative"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsDown")})]})]})},pd2=({message:a,handleActionEvent:t,close:n,className:l})=>{const[o,i]=e.useState(""),[s,u]=e.useState(!1),A=p=>{p.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),setTimeout(()=>{u(!1),n()},500)};return _.jsxs("form",{"data-testid":"feedback-form",onSubmit:A,className:q2("mt-auto flex flex-col gap-2",l),children:[_.jsx(bd,{className:"border-0 bg-white text-base text-black shadow-none ring-0 focus-visible:ring-0 widget:text-sm",placeholder:"Share your thoughts here..",value:o,disabled:s,"data-testid":"feedback-form-textarea",onChange:p=>i(p.target.value)}),_.jsx(ua,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:"Send"})]})},fd2=({message:a,index:t,isLast:n,isLastInGroup:l,isFirstInGroup:o,...i})=>{var C;const{state:s,handleActionEvent:u}=we(),{messages:A,userId:p}=s,g=t===A.length-1,V=p?hc(a,p):!1,v=V?"sent":"received",L=V?"default":"ai";return _.jsx("div",{...i,children:_.jsxs(ed0,{settings:s.settings,testId:t.toString(),variant:v,isFirstInGroup:o,isLastInGroup:l,sentAt:g?a.sent_at:null,userName:a.sender_name?a.sender_name:(C=s.settings)==null?void 0:C.digitalEmployeeName,className:"",children:[a.blocks.map(I=>P21(I,v,L)),a.request_user_feedback&&!V&&_.jsx(Ad2,{message:a,handleActionEvent:u})]})})},Zd2=()=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("div",{className:"bubble1 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble2 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble3 h-2 w-2 rounded-full"})]}),Hd2=()=>{var t;const{state:a}=we();return _.jsx(ed0,{settings:a.settings,userName:(t=a.settings)==null?void 0:t.digitalEmployeeName,testId:"loading",variant:"received",isFirstInGroup:!0,isLastInGroup:!1,sentAt:null,className:"",children:_.jsx(Ui,{variant:"received",layout:"ai",className:"prose max-w-[60%]",children:_.jsx(Zd2,{})})},"message-loading")},gd2=150,Ed2=a=>{const[t,n]=e.useState(!1),l=e.useCallback(()=>{if(!a)return;const{scrollTop:i,scrollHeight:s,clientHeight:u}=a,A=s-i-u;n(A>gd2)},[a]);return e.useEffect(()=>{if(a)return l(),a.addEventListener("scroll",l),()=>{a.removeEventListener("scroll",l)}},[a,l]),{scrollToBottom:()=>{a==null||a.scrollTo({top:a.scrollHeight,behavior:"smooth"})},isScrolledUp:t}},Vd2=()=>{var o;const{t:a}=Le(),{state:t}=we(),n=e.useMemo(()=>{const i=u=>u.type==="text"||u.type==="markdown",s=t.messages.filter(u=>!hc(u,t.userId)&&u.type==="message"&&u.blocks.some(i)).slice(-1)[0];return(s==null?void 0:s.blocks.filter(i))??[]},[t.messages,t.userId]),l=`${((o=t.settings)==null?void 0:o.title)??a("common:bot")} ${a("header:typing")}`;return _.jsx("div",{className:"sr-only","aria-live":"polite",children:t.isTyping?l:n.map(i=>P21(i,"sent","default"))})};function Md2(a){return a?a.map(t=>({...t,blocks:t.blocks?t.blocks.filter(n=>ud2(n.type)):[]})):[]}function vd2(a){return a?a.filter(t=>t.blocks&&t.blocks.length>0):[]}const Ld2=({href:a="",children:t,...n})=>_.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...n,children:t}),wd2=68;function yd2(){var L,C,I,T,N;const a=e.useRef(null),{state:t,endDivRef:n,scrollableDivRef:l}=we(),{scrollToBottom:o,isScrolledUp:i}=Ed2(l.current),[s,u]=e.useState(!1),A=e.useMemo(()=>{const D=Md2(t.messages);return vd2(D)},[t.messages]),p=e.useMemo(()=>A.length>0&&hc(A[A.length-1],t.userId),[A,t.userId]);e.useEffect(()=>{t.isWaitingOnFirstStream&&setTimeout(()=>{var D;(D=l.current)==null||D.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})},100)},[t.isWaitingOnFirstStream]),e.useEffect(()=>{!s&&t.messages.length>0&&(u(!0),setTimeout(()=>{var D,B;(B=l.current)==null||B.scrollTo({top:(D=l.current)==null?void 0:D.scrollHeight})},0))},[t.messages,s]);const g=((L=l.current)==null?void 0:L.clientHeight)||0,V=wd2+(((C=a.current)==null?void 0:C.clientHeight)||0),v=`${g-V}px`;return _.jsxs("div",{className:"relative h-full w-full",children:[_.jsx(Vd2,{}),_.jsxs("div",{className:"flex h-full w-full flex-col overflow-y-auto",ref:l,children:[_.jsxs("div",{className:"flex grow flex-col gap-3 px-4 py-2",children:[((I=t.settings)==null?void 0:I.disclaimer)&&_.jsx("div",{children:_.jsx(O01,{rehypePlugins:[a21],className:"!m-0 max-w-none text-center text-[10px] leading-[14px] text-gray-500",skipHtml:!0,components:{a:Ld2},children:(T=t.settings)==null?void 0:T.disclaimer})}),A.map((D,B)=>{const q=B===A.length-1,G=A[B+1],z=A[B-1],X=G?D.sender_id!==G.sender_id:!0,J=z?D.sender_id!==z.sender_id:!0;return _.jsx(fd2,{message:D,index:B,isLast:q,isLastInGroup:X,isFirstInGroup:J,style:{minHeight:q&&t.hasSentMessageThisSession&&!p?v:void 0}},`message-${D.id}-${B}`)}),p&&_.jsx("div",{style:{minHeight:t.hasSentMessageThisSession?v:void 0},children:t.isTyping&&_.jsx(Hd2,{})})]}),((N=t.settings)==null?void 0:N.showFreedayBranding)&&_.jsx(ku0,{ref:a,name:"Freeday",site:"https://freeday.ai",className:"shrink-0 pb-4 pt-8"})]}),_.jsx("div",{ref:n}),i&&_.jsx(ua,{variant:"outline",size:"icon",onClick:o,className:"absolute bottom-2 left-1/2 -translate-x-1/2 border border-border p-1",children:_.jsx(Ah,{size:18})})]})}const Fd2=()=>{var u,A,p,g;const{state:a}=we(),{t}=Le(),[n,l]=e.useState(!0),[o,i]=e.useState(!1);e.useEffect(()=>{const V=setTimeout(()=>{i(!0)},300);return()=>clearTimeout(V)},[]),e.useEffect(()=>{if(!n)return;const V=v=>{!o||v.target.closest('[data-testid="chat-button"]')||l(!1)};return window.addEventListener("click",V),window.addEventListener("touchstart",V),()=>{window.removeEventListener("click",V),window.removeEventListener("touchstart",V)}},[o,n]);const s=()=>{l(!1)};return(u=a.settings)!=null&&u.bannerTitle&&n?_.jsx("div",{className:"pb-7.5 absolute left-0 right-0 top-0 max-h-[500px] -translate-y-full gap-4 overflow-hidden rounded-t-[30px] bg-white transition-all duration-300 ease-in-out","data-testid":"banner",children:_.jsxs("div",{className:"flex h-full w-full flex-col justify-center rounded-t-[30px] bg-primary/10 p-6",children:[_.jsx("button",{onClick:s,className:"absolute right-8 top-8 flex -translate-y-1/2 translate-x-1/2 cursor-pointer rounded p-1 hover:bg-primary/10 focus:outline-none focus:ring-2 focus:ring-primary","aria-label":t("common:closeNotification"),"data-testid":"close-button",children:_.jsx(Xn,{weight:"regular",size:20,className:"text-primary"})}),_.jsx("p",{className:"text-sm font-semibold text-primary",children:(A=a.settings)==null?void 0:A.bannerTitle}),((p=a.settings)==null?void 0:p.bannerMessage)&&_.jsx("p",{className:"whitespace-pre-line text-sm",children:(g=a.settings)==null?void 0:g.bannerMessage})]})}):null},Cd2=({placeholder:a,isTyping:t,onSendMessage:n})=>{const{t:l}=Le(),[o,i]=e.useState(""),[s,u]=e.useState(!0),A=e.useRef(null),p=L=>{i(L.target.value)};e.useEffect(()=>{u(o.trim().length===0||t)},[o,t]);const g=L=>{L==null||L.preventDefault(),!s&&(n(o),i(""))},V=L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),g(L))},v=()=>q2("absolute right-2 top-1/2 flex h-9 w-9 -translate-y-1/2 transform items-center justify-center rounded p-0 transition-all duration-0 ease-in-out",o.trim().length>0?"text-primary":"text-gray-300");return _.jsx("footer",{className:"relative bottom-0 left-0 right-0 border-t border-gray-200 bg-white",children:_.jsxs("div",{className:"p-4",children:[_.jsx(Fd2,{}),_.jsx("form",{onSubmit:g,children:_.jsx("div",{className:"flex w-full max-w-full items-center space-x-2",children:_.jsxs("div",{className:"relative w-full flex-1",ref:A,children:[_.jsxs("div",{className:"invisible max-h-[164px] min-h-[44px] overflow-y-hidden whitespace-pre-wrap break-words px-4 py-2",children:[o||a,"|"]}),_.jsx("label",{htmlFor:"chat-input-textarea",className:"sr-only",children:a}),_.jsx("textarea",{id:"chat-input-textarea",className:"absolute inset-0 resize-none rounded-3xl border border-gray-300 pb-[0px] pl-[16px] pr-[48px] pt-[10px] text-[16px] leading-[20px] placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-primary",placeholder:a,wrap:"hard","data-testid":"text-input-field",value:o,onKeyDown:V,onChange:p,rows:1}),t?_.jsx("div",{"data-testid":"stop-button",className:v(),children:_.jsx($h,{weight:"bold",className:"h-6 w-6"})}):_.jsx("button",{"data-testid":"send-button",className:v(),"aria-label":l("common:send"),children:_.jsx(zc,{weight:"fill",className:"h-6 w-6"})})]})})})]})})},bd2=()=>{var l,o;const{t:a}=Le(["common","footer"]),{sendNewMessage:t,state:n}=we();return _.jsxs(_.Fragment,{children:[((l=n.settings)==null?void 0:l.theme)!=="slim"&&_.jsx(Wr2,{}),_.jsx(w52,{position:"top-center",expand:!0,pauseWhenPageIsHidden:!0,richColors:!0}),_.jsx("main",{className:"flex-1 space-y-2 overflow-hidden bg-white",children:_.jsx(T7,{initial:!0,children:_.jsx(nl.div,{className:"h-full w-full",initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{duration:.3,ease:[.42,0,0,1],delay:.4},children:_.jsx(yd2,{})})})}),_.jsx(Cd2,{placeholder:a(((o=n.settings)==null?void 0:o.newMessagePlaceholder)??a("footer:newMessagePlaceholder")),isTyping:n.isTyping,onSendMessage:t})]})},Id2=a=>{const[t,n]=e.useState(null);return e.useEffect(()=>{if(!a)return;(async()=>{try{const i=await new qg0(a,new yH(kZ0())).fetchWidgetSettings();n(i)}catch(o){W6(o)}})()},[a]),{widgetSettings:t}},Sd2=(a=!1)=>{const[t,n]=e.useState(a),[l,o]=e.useState(!1);return e.useEffect(()=>{const i=s=>{s.type===x8.CLOSE?(n(!1),o(!0)):s.type===x8.OPEN&&(n(!0),o(!1))};return globalThis.addEventListener(x8.CLOSE,i),globalThis.addEventListener(x8.OPEN,i),()=>{globalThis.removeEventListener(x8.CLOSE,i),globalThis.removeEventListener(x8.OPEN,i)}},[]),{isWidgetOpen:t,setIsWidgetOpen:n,hideChatBarInput:l}},Rd2=a=>{const t=sE0();return{handleOpen:()=>{t.capture("widget:opened",{start_view:a==null?void 0:a.startView}),globalThis.dispatchEvent(new Event(x8.OPEN)),globalThis.postMessage({event:x8.START,payload:a},globalThis.location.origin)},handleOpenAndSendMessage:o=>{setTimeout(()=>{globalThis.postMessage({event:x8.START,payload:{suggestionMessage:o}},globalThis.location.origin),globalThis.dispatchEvent(new Event(x8.OPEN))},400)}}},Td2="https://cdn.jsdelivr.net/npm/@freeday-ai/webchat",xd2=()=>{e.useEffect(()=>{const a=n=>{O21(n.error)},t=n=>{O21(n.reason)};return globalThis.addEventListener("error",a),globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("error",a),globalThis.removeEventListener("unhandledrejection",t)}},[])},O21=a=>{var t;(t=a==null?void 0:a.stack)!=null&&t.includes(Td2)&&W6(a)};class Nd2 extends e.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){W6(t,"Uncaught rendering error",{componentStack:n.componentStack})}render(){return this.props.children}}const $d2=({channelId:a,metadata:t})=>{xd2();const{widgetSettings:n}=Id2(a);return!a||!n?null:_.jsx(Nd2,{children:_.jsx(Xr1,{config:{...n,metadata:t?JSON.parse(t):void 0},inShadowDom:!0,children:_.jsx(Dd2,{widgetSettings:{...n,metadata:t?JSON.parse(t):void 0}})})})};function kd2(){e.useEffect(()=>{if(!/Mobi|Android/i.test(navigator.userAgent))return;const t=document.querySelector(".widget-chat-container");if(!t)return;const n=()=>{t.style.height=`${window.innerHeight}px`};n(),window.addEventListener("resize",n);const l=t.querySelector("#chat-input-textarea"),o=i=>{const s=i.target;s&&setTimeout(()=>{s.scrollIntoView({behavior:"smooth",block:"center"})},300)};return l==null||l.addEventListener("focus",o),()=>{window.removeEventListener("resize",n),l==null||l.removeEventListener("focus",o),t.style.height=""}},[])}const Dd2=({widgetSettings:a})=>{const t=a.startView===F3.FULL_SCREEN,n=a.startView===F3.UNFOLDED_CHAT_VIEW,l=t||n,{isWidgetOpen:o,setIsWidgetOpen:i}=Sd2(l),{handleOpen:s,handleOpenAndSendMessage:u}=Rd2(a);return kd2(),e.useEffect(()=>{if(!l)return;i(!0);const A=requestAnimationFrame(s);return()=>cancelAnimationFrame(A)},[]),_.jsxs(_.Fragment,{children:[_.jsx(T7,{children:o&&_.jsx(nl.div,{className:q2("chat-window-renderer",{"full-screen":t}),"data-testid":"chat-window-renderer",initial:{opacity:0,y:30},animate:{opacity:1,y:0,transition:{delay:.2}},exit:{opacity:0,y:30},transition:{duration:.35,ease:[.42,0,0,1]},transformTemplate:t?(A,p)=>`translateX(-50%) ${p}`:void 0,children:_.jsx(nr2,{children:_.jsx("div",{className:"widget-chat-container flex flex-col",children:_.jsx(bd2,{})})})})}),!t&&_.jsx(T7,{children:!o&&_.jsx(nl.div,{className:"button-container",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{delay:.3}},exit:{opacity:0,scale:0},transition:{duration:.3,ease:[.42,0,0,1]},children:_.jsx(z32,{onOpen:s,onSendMessage:u})})})]})};B41("freeday-widget",$d2,["channelId","metadata"]);const _21=a=>{const{channelId:t,metadata:n}=a,l=document.createElement("div"),o=document.createElement("freeday-widget");o.setAttribute("channelId",t),n&&o.setAttribute("metadata",JSON.stringify(n)),l.appendChild(o),document.body?document.body.appendChild(l):window.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(l)})};return window.FreedayWidget={bootstrap:_21},Xf.bootstrap=_21,Object.defineProperty(Xf,Symbol.toStringTag,{value:"Module"}),Xf})({});
|
|
330
|
+
`))}function A(L,C,I,T){const N=I.enter("tableCell"),D=I.enter("phrasing"),B=I.containerPhrasing(L,{...T,before:i,after:i});return D(),N(),B}function p(L,C){return Su2(L,{align:C,alignDelimiters:l,padding:n,stringLength:o})}function g(L,C,I){const T=L.children;let N=-1;const D=[],B=C.enter("table");for(;++N<T.length;)D[N]=V(T[N],C,I);return B(),D}function V(L,C,I){const T=L.children;let N=-1;const D=[],B=C.enter("tableRow");for(;++N<T.length;)D[N]=A(T[N],L,C,I);return B(),D}function v(L,C,I){let T=E21.inlineCode(L,C,I);return I.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function Hh2(){return{exit:{taskListCheckValueChecked:M21,taskListCheckValueUnchecked:M21,paragraph:Eh2}}}function gh2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Vh2}}}function M21(a){const t=this.stack[this.stack.length-2];t.type,t.checked=a.type==="taskListCheckValueChecked"}function Eh2(a){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const l=n.children[0];if(l&&l.type==="text"){const o=t.children;let i=-1,s;for(;++i<o.length;){const u=o[i];if(u.type==="paragraph"){s=u;break}}s===n&&(l.value=l.value.slice(1),l.value.length===0?n.children.shift():n.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,n.position.start=Object.assign({},l.position.start)))}}this.exit(a)}function Vh2(a,t,n,l){const o=a.children[0],i=typeof a.checked=="boolean"&&o&&o.type==="paragraph",s="["+(a.checked?"x":" ")+"] ",u=n.createTracker(l);i&&u.move(s);let A=E21.listItem(a,t,n,{...l,...u.current()});return i&&(A=A.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),A;function p(g){return g+s}}function Mh2(){return[eu2(),Vu2(),wu2(),uh2(),Hh2()]}function vh2(a){return{extensions:[au2(),Mu2(a),yu2(),Zh2(a),gh2()]}}const Lh2={tokenize:Ih2,partial:!0},v21={tokenize:Sh2,partial:!0},L21={tokenize:Rh2,partial:!0},w21={tokenize:Th2,partial:!0},wh2={tokenize:xh2,partial:!0},y21={name:"wwwAutolink",tokenize:Ch2,previous:C21},F21={name:"protocolAutolink",tokenize:bh2,previous:b21},z3={name:"emailAutolink",tokenize:Fh2,previous:I21},Bt={};function yh2(){return{text:Bt}}let jr=48;for(;jr<123;)Bt[jr]=z3,jr++,jr===58?jr=65:jr===91&&(jr=97);Bt[43]=z3,Bt[45]=z3,Bt[46]=z3,Bt[95]=z3,Bt[72]=[z3,F21],Bt[104]=[z3,F21],Bt[87]=[z3,y21],Bt[119]=[z3,y21];function Fh2(a,t,n){const l=this;let o,i;return s;function s(V){return!Qh0(V)||!I21.call(l,l.previous)||Jh0(l.events)?n(V):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),u(V))}function u(V){return Qh0(V)?(a.consume(V),u):V===64?(a.consume(V),A):n(V)}function A(V){return V===46?a.check(wh2,g,p)(V):V===45||V===95||be(V)?(i=!0,a.consume(V),A):g(V)}function p(V){return a.consume(V),o=!0,A}function g(V){return i&&o&&Qe(l.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),t(V)):n(V)}}function Ch2(a,t,n){const l=this;return o;function o(s){return s!==87&&s!==119||!C21.call(l,l.previous)||Jh0(l.events)?n(s):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(Lh2,a.attempt(v21,a.attempt(L21,i),n),n)(s))}function i(s){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),t(s)}}function bh2(a,t,n){const l=this;let o="",i=!1;return s;function s(V){return(V===72||V===104)&&b21.call(l,l.previous)&&!Jh0(l.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),o+=String.fromCodePoint(V),a.consume(V),u):n(V)}function u(V){if(Qe(V)&&o.length<5)return o+=String.fromCodePoint(V),a.consume(V),u;if(V===58){const v=o.toLowerCase();if(v==="http"||v==="https")return a.consume(V),A}return n(V)}function A(V){return V===47?(a.consume(V),i?p:(i=!0,A)):n(V)}function p(V){return V===null||Nd(V)||M8(V)||Or(V)||$d(V)?n(V):a.attempt(v21,a.attempt(L21,g),n)(V)}function g(V){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),t(V)}}function Ih2(a,t,n){let l=0;return o;function o(s){return(s===87||s===119)&&l<3?(l++,a.consume(s),o):s===46&&l===3?(a.consume(s),i):n(s)}function i(s){return s===null?n(s):t(s)}}function Sh2(a,t,n){let l,o,i;return s;function s(p){return p===46||p===95?a.check(w21,A,u)(p):p===null||M8(p)||Or(p)||p!==45&&$d(p)?A(p):(i=!0,a.consume(p),s)}function u(p){return p===95?l=!0:(o=l,l=void 0),a.consume(p),s}function A(p){return o||l||!i?n(p):t(p)}}function Rh2(a,t){let n=0,l=0;return o;function o(s){return s===40?(n++,a.consume(s),o):s===41&&l<n?i(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?a.check(w21,t,i)(s):s===null||M8(s)||Or(s)?t(s):(a.consume(s),o)}function i(s){return s===41&&l++,a.consume(s),o}}function Th2(a,t,n){return l;function l(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(a.consume(u),l):u===38?(a.consume(u),i):u===93?(a.consume(u),o):u===60||u===null||M8(u)||Or(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||M8(u)||Or(u)?t(u):l(u)}function i(u){return Qe(u)?s(u):n(u)}function s(u){return u===59?(a.consume(u),l):Qe(u)?(a.consume(u),s):n(u)}}function xh2(a,t,n){return l;function l(i){return a.consume(i),o}function o(i){return be(i)?n(i):t(i)}}function C21(a){return a===null||a===40||a===42||a===95||a===91||a===93||a===126||M8(a)}function b21(a){return!Qe(a)}function I21(a){return!(a===47||Qh0(a))}function Qh0(a){return a===43||a===45||a===46||a===95||be(a)}function Jh0(a){let t=a.length,n=!1;for(;t--;){const l=a[t][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){n=!0;break}if(l._gfmAutolinkLiteralWalkedInto){n=!1;break}}return a.length>0&&!n&&(a[a.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Nh2={tokenize:Uh2,partial:!0};function $h2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Oh2,continuation:{tokenize:_h2},exit:Bh2}},text:{91:{name:"gfmFootnoteCall",tokenize:Ph2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kh2,resolveTo:Dh2}}}}function kh2(a,t,n){const l=this;let o=l.events.length;const i=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let s;for(;o--;){const A=l.events[o][1];if(A.type==="labelImage"){s=A;break}if(A.type==="gfmFootnoteCall"||A.type==="labelLink"||A.type==="label"||A.type==="image"||A.type==="link")break}return u;function u(A){if(!s||!s._balanced)return n(A);const p=Wa(l.sliceSerialize({start:s.end,end:l.now()}));return p.codePointAt(0)!==94||!i.includes(p.slice(1))?n(A):(a.enter("gfmFootnoteCallLabelMarker"),a.consume(A),a.exit("gfmFootnoteCallLabelMarker"),t(A))}}function Dh2(a,t){let n=a.length;for(;n--;)if(a[n][1].type==="labelImage"&&a[n][0]==="enter"){a[n][1];break}a[n+1][1].type="data",a[n+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},a[n+3][1].start),end:Object.assign({},a[a.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},a[n+3][1].end),end:Object.assign({},a[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},a[a.length-1][1].start)},s={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},u=[a[n+1],a[n+2],["enter",l,t],a[n+3],a[n+4],["enter",o,t],["exit",o,t],["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t],a[a.length-2],a[a.length-1],["exit",l,t]];return a.splice(n,a.length-n+1,...u),a}function Ph2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i=0,s;return u;function u(V){return a.enter("gfmFootnoteCall"),a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),A}function A(V){return V!==94?n(V):(a.enter("gfmFootnoteCallMarker"),a.consume(V),a.exit("gfmFootnoteCallMarker"),a.enter("gfmFootnoteCallString"),a.enter("chunkString").contentType="string",p)}function p(V){if(i>999||V===93&&!s||V===null||V===91||M8(V))return n(V);if(V===93){a.exit("chunkString");const v=a.exit("gfmFootnoteCallString");return o.includes(Wa(l.sliceSerialize(v)))?(a.enter("gfmFootnoteCallLabelMarker"),a.consume(V),a.exit("gfmFootnoteCallLabelMarker"),a.exit("gfmFootnoteCall"),t):n(V)}return M8(V)||(s=!0),i++,a.consume(V),V===92?g:p}function g(V){return V===91||V===92||V===93?(a.consume(V),i++,p):p(V)}}function Oh2(a,t,n){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let i,s=0,u;return A;function A(C){return a.enter("gfmFootnoteDefinition")._container=!0,a.enter("gfmFootnoteDefinitionLabel"),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(C),a.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(C){return C===94?(a.enter("gfmFootnoteDefinitionMarker"),a.consume(C),a.exit("gfmFootnoteDefinitionMarker"),a.enter("gfmFootnoteDefinitionLabelString"),a.enter("chunkString").contentType="string",g):n(C)}function g(C){if(s>999||C===93&&!u||C===null||C===91||M8(C))return n(C);if(C===93){a.exit("chunkString");const I=a.exit("gfmFootnoteDefinitionLabelString");return i=Wa(l.sliceSerialize(I)),a.enter("gfmFootnoteDefinitionLabelMarker"),a.consume(C),a.exit("gfmFootnoteDefinitionLabelMarker"),a.exit("gfmFootnoteDefinitionLabel"),v}return M8(C)||(u=!0),s++,a.consume(C),C===92?V:g}function V(C){return C===91||C===92||C===93?(a.consume(C),s++,g):g(C)}function v(C){return C===58?(a.enter("definitionMarker"),a.consume(C),a.exit("definitionMarker"),o.includes(i)||o.push(i),W2(a,L,"gfmFootnoteDefinitionWhitespace")):n(C)}function L(C){return t(C)}}function _h2(a,t,n){return a.check(Li,t,a.attempt(Nh2,t,n))}function Bh2(a){a.exit("gfmFootnoteDefinition")}function Uh2(a,t,n){const l=this;return W2(a,o,"gfmFootnoteDefinitionIndent",5);function o(i){const s=l.events[l.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(i):n(i)}}function zh2(a){let n=(a||{}).singleTilde;const l={name:"strikethrough",tokenize:i,resolveAll:o};return n==null&&(n=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(s,u){let A=-1;for(;++A<s.length;)if(s[A][0]==="enter"&&s[A][1].type==="strikethroughSequenceTemporary"&&s[A][1]._close){let p=A;for(;p--;)if(s[p][0]==="exit"&&s[p][1].type==="strikethroughSequenceTemporary"&&s[p][1]._open&&s[A][1].end.offset-s[A][1].start.offset===s[p][1].end.offset-s[p][1].start.offset){s[A][1].type="strikethroughSequence",s[p][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},s[p][1].start),end:Object.assign({},s[A][1].end)},V={type:"strikethroughText",start:Object.assign({},s[p][1].end),end:Object.assign({},s[A][1].start)},v=[["enter",g,u],["enter",s[p][1],u],["exit",s[p][1],u],["enter",V,u]],L=u.parser.constructs.insideSpan.null;L&&j4(v,v.length,0,kd(L,s.slice(p+1,A),u)),j4(v,v.length,0,[["exit",V,u],["enter",s[A][1],u],["exit",s[A][1],u],["exit",g,u]]),j4(s,p-1,A-p+3,v),A=p+v.length-2;break}}for(A=-1;++A<s.length;)s[A][1].type==="strikethroughSequenceTemporary"&&(s[A][1].type="data");return s}function i(s,u,A){const p=this.previous,g=this.events;let V=0;return v;function v(C){return p===126&&g[g.length-1][1].type!=="characterEscape"?A(C):(s.enter("strikethroughSequenceTemporary"),L(C))}function L(C){const I=t9(p);if(C===126)return V>1?A(C):(s.consume(C),V++,L);if(V<2&&!n)return A(C);const T=s.exit("strikethroughSequenceTemporary"),N=t9(C);return T._open=!N||N===2&&!!I,T._close=!I||I===2&&!!N,u(C)}}}class jh2{constructor(){this.map=[]}add(t,n,l){qh2(this,t,n,l)}consume(t){if(this.map.sort(function(i,s){return i[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const l=[];for(;n>0;)n-=1,l.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];l.push(t.slice()),t.length=0;let o=l.pop();for(;o;){for(const i of o)t.push(i);o=l.pop()}this.map.length=0}}function qh2(a,t,n,l){let o=0;if(!(n===0&&l.length===0)){for(;o<a.map.length;){if(a.map[o][0]===t){a.map[o][1]+=n,a.map[o][2].push(...l);return}o+=1}a.map.push([t,n,l])}}function Wh2(a,t){let n=!1;const l=[];for(;t<a.length;){const o=a[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&l.push(a[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(a[t-1][1].type==="tableDelimiterMarker"){const i=l.length-1;l[i]=l[i]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return l}function Gh2(){return{flow:{null:{name:"table",tokenize:Yh2,resolveAll:Kh2}}}}function Yh2(a,t,n){const l=this;let o=0,i=0,s;return u;function u(Q){let f0=l.events.length-1;for(;f0>-1;){const s0=l.events[f0][1].type;if(s0==="lineEnding"||s0==="linePrefix")f0--;else break}const t0=f0>-1?l.events[f0][1].type:null,c0=t0==="tableHead"||t0==="tableRow"?z:A;return c0===z&&l.parser.lazy[l.now().line]?n(Q):c0(Q)}function A(Q){return a.enter("tableHead"),a.enter("tableRow"),p(Q)}function p(Q){return Q===124||(s=!0,i+=1),g(Q)}function g(Q){return Q===null?n(Q):Q1(Q)?i>1?(i=0,l.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(Q),a.exit("lineEnding"),L):n(Q):_2(Q)?W2(a,g,"whitespace")(Q):(i+=1,s&&(s=!1,o+=1),Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),s=!0,g):(a.enter("data"),V(Q)))}function V(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),g(Q)):(a.consume(Q),Q===92?v:V)}function v(Q){return Q===92||Q===124?(a.consume(Q),V):V(Q)}function L(Q){return l.interrupt=!1,l.parser.lazy[l.now().line]?n(Q):(a.enter("tableDelimiterRow"),s=!1,_2(Q)?W2(a,C,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):C(Q))}function C(Q){return Q===45||Q===58?T(Q):Q===124?(s=!0,a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),I):G(Q)}function I(Q){return _2(Q)?W2(a,T,"whitespace")(Q):T(Q)}function T(Q){return Q===58?(i+=1,s=!0,a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),N):Q===45?(i+=1,N(Q)):Q===null||Q1(Q)?q(Q):G(Q)}function N(Q){return Q===45?(a.enter("tableDelimiterFiller"),D(Q)):G(Q)}function D(Q){return Q===45?(a.consume(Q),D):Q===58?(s=!0,a.exit("tableDelimiterFiller"),a.enter("tableDelimiterMarker"),a.consume(Q),a.exit("tableDelimiterMarker"),B):(a.exit("tableDelimiterFiller"),B(Q))}function B(Q){return _2(Q)?W2(a,q,"whitespace")(Q):q(Q)}function q(Q){return Q===124?C(Q):Q===null||Q1(Q)?!s||o!==i?G(Q):(a.exit("tableDelimiterRow"),a.exit("tableHead"),t(Q)):G(Q)}function G(Q){return n(Q)}function z(Q){return a.enter("tableRow"),X(Q)}function X(Q){return Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),X):Q===null||Q1(Q)?(a.exit("tableRow"),t(Q)):_2(Q)?W2(a,X,"whitespace")(Q):(a.enter("data"),J(Q))}function J(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),X(Q)):(a.consume(Q),Q===92?Z0:J)}function Z0(Q){return Q===92||Q===124?(a.consume(Q),J):J(Q)}}function Kh2(a,t){let n=-1,l=!0,o=0,i=[0,0,0,0],s=[0,0,0,0],u=!1,A=0,p,g,V;const v=new jh2;for(;++n<a.length;){const L=a[n],C=L[1];L[0]==="enter"?C.type==="tableHead"?(u=!1,A!==0&&(S21(v,t,A,p,g),g=void 0,A=0),p={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(n,0,[["enter",p,t]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(l=!0,V=void 0,i=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,g={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(n,0,[["enter",g,t]])),o=C.type==="tableDelimiterRow"?2:g?3:1):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(l=!1,s[2]===0&&(i[1]!==0&&(s[0]=s[1],V=lA(v,t,i,o,void 0,V),i=[0,0,0,0]),s[2]=n)):C.type==="tableCellDivider"&&(l?l=!1:(i[1]!==0&&(s[0]=s[1],V=lA(v,t,i,o,void 0,V)),i=s,s=[i[1],n,0,0])):C.type==="tableHead"?(u=!0,A=n):C.type==="tableRow"||C.type==="tableDelimiterRow"?(A=n,i[1]!==0?(s[0]=s[1],V=lA(v,t,i,o,n,V)):s[1]!==0&&(V=lA(v,t,s,o,n,V)),o=0):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(s[3]=n)}for(A!==0&&S21(v,t,A,p,g),v.consume(t.events),n=-1;++n<t.events.length;){const L=t.events[n];L[0]==="enter"&&L[1].type==="table"&&(L[1]._align=Wh2(t.events,n))}return a}function lA(a,t,n,l,o,i){const s=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(i.end=Object.assign({},h9(t.events,n[0])),a.add(n[0],0,[["exit",i,t]]));const A=h9(t.events,n[1]);if(i={type:s,start:Object.assign({},A),end:Object.assign({},A)},a.add(n[1],0,[["enter",i,t]]),n[2]!==0){const p=h9(t.events,n[2]),g=h9(t.events,n[3]),V={type:u,start:Object.assign({},p),end:Object.assign({},g)};if(a.add(n[2],0,[["enter",V,t]]),l!==2){const v=t.events[n[2]],L=t.events[n[3]];if(v[1].end=Object.assign({},L[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const C=n[2]+1,I=n[3]-n[2]-1;a.add(C,I,[])}}a.add(n[3]+1,0,[["exit",V,t]])}return o!==void 0&&(i.end=Object.assign({},h9(t.events,o)),a.add(o,0,[["exit",i,t]]),i=void 0),i}function S21(a,t,n,l,o){const i=[],s=h9(t.events,n);o&&(o.end=Object.assign({},s),i.push(["exit",o,t])),l.end=Object.assign({},s),i.push(["exit",l,t]),a.add(n+1,0,i)}function h9(a,t){const n=a[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const Xh2={name:"tasklistCheck",tokenize:Jh2};function Qh2(){return{text:{91:Xh2}}}function Jh2(a,t,n){const l=this;return o;function o(A){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?n(A):(a.enter("taskListCheck"),a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),i)}function i(A){return M8(A)?(a.enter("taskListCheckValueUnchecked"),a.consume(A),a.exit("taskListCheckValueUnchecked"),s):A===88||A===120?(a.enter("taskListCheckValueChecked"),a.consume(A),a.exit("taskListCheckValueChecked"),s):n(A)}function s(A){return A===93?(a.enter("taskListCheckMarker"),a.consume(A),a.exit("taskListCheckMarker"),a.exit("taskListCheck"),u):n(A)}function u(A){return Q1(A)?t(A):_2(A)?a.check({tokenize:ed2},t,n)(A):n(A)}}function ed2(a,t,n){return W2(a,l,"whitespace");function l(o){return o===null?n(o):t(o)}}function ad2(a){return KJ0([yh2(),$h2(),zh2(a),Gh2(),Qh2()])}const td2={};function nd2(a){const t=this,n=a||td2,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),i=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(ad2(n)),i.push(Mh2()),s.push(vh2(n))}const ld2=$u0("relative flex w-full flex-col gap-3",{variants:{variant:{received:"items-start",sent:"items-end"},layout:{user:"",ai:"w-full max-w-full items-center"},isLastInGroup:{true:"",false:""}},defaultVariants:{variant:"received",layout:"user"}}),ed0=e.forwardRef(({settings:a,className:t,variant:n,isLastInGroup:l,isFirstInGroup:o,sentAt:i,layout:s,children:u,testId:A="",userName:p,...g},V)=>_.jsxs("div",{"data-testid":n=="received"?`chat-message-${A} incoming-message-${A}`:`chat-message-${A} outgoing-message-${A}`,children:[n&&o&&od2({variant:n,settings:a,userName:p}),_.jsx("div",{className:q2(ld2({variant:n,layout:s,isLastInGroup:l,className:t}),a!=null&&a.avatar?"pl-6":""),ref:V,...g,children:u})]}));ed0.displayName="Message";const rd2=$u0("p-4",{variants:{variant:{received:"message-received",sent:"message-send"},layout:{default:"",ai:"message-ai"},isLoading:{true:"animate-pulse bg-gray-200",false:""}},defaultVariants:{variant:"received",layout:"default"}}),Ui=e.forwardRef(({className:a,variant:t,layout:n,isLoading:l=!1,children:o,...i},s)=>_.jsx("div",{className:q2(rd2({variant:t,layout:n,isLoading:l,className:a}),"overflow-x-auto break-words"),ref:s,...i,children:o}));Ui.displayName="MessageBubble";const od2=({variant:a,settings:t,userName:n})=>a!=="received"?null:_.jsxs("div",{className:"mb-1 flex items-center justify-start space-x-1",children:[(t==null?void 0:t.avatar)&&_.jsx("img",{width:48,height:48,className:"mt-1 h-5 w-5 rounded-full",src:t.avatar,alt:"Avatar"}),n&&_.jsx("span",{className:"font-brand text-[11.2px] font-bold leading-[16.8px] text-primary",children:n})]}),cd2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(Ui,{variant:t,layout:n,isLoading:l,className:"prose max-w-[95%] break-words prose-a:text-blue-600",children:_.jsx(O01,{rehypePlugins:[a21],remarkPlugins:[nd2],components:{a:id2},className:"",skipHtml:!0,children:a.content})});function id2(a){return _.jsx("a",{href:a.href,target:"_blank",children:a.children})}const R21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));R21.displayName="Card";const T21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("flex flex-col space-y-1.5 p-6",a),...t}));T21.displayName="CardHeader";const x21=e.forwardRef(({className:a,...t},n)=>_.jsx("h3",{ref:n,className:q2("text-2xl font-semibold leading-none tracking-tight",a),...t}));x21.displayName="CardTitle";const N21=e.forwardRef(({className:a,...t},n)=>_.jsx("p",{ref:n,className:q2("text-sm text-muted-foreground",a),...t}));N21.displayName="CardDescription";const $21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("p-6 pt-0",a),...t}));$21.displayName="CardContent";const k21=e.forwardRef(({className:a,...t},n)=>_.jsx("div",{ref:n,className:q2("flex items-center p-6 pt-0",a),...t}));k21.displayName="CardFooter";const sd2=({block:a})=>{const{t}=Le("common");return a.sources.some(l=>l.document_metadata&&l.document_metadata.card)?_.jsx("div",{className:"flex w-full max-w-full gap-5 overflow-x-auto",children:a.sources.map(l=>_.jsxs(R21,{"data-url":l.source_link,className:"min-w-[200px] max-w-72 overflow-hidden",children:[_.jsx(T21,{className:"h-full max-h-[120px] p-0",children:_.jsx("img",{className:"h-full w-full object-cover transition duration-300 ease-in-out group-hover:scale-105",src:l.document_metadata.card.image,alt:l.document_metadata.card.title})}),_.jsxs($21,{className:"p-4",children:[_.jsx(x21,{className:"text-md line-clamp-1 font-bold",children:l.document_metadata.card.title}),l.document_metadata.card.description&&_.jsx(N21,{className:"line-clamp-2 text-sm",children:l.document_metadata.card.description})]}),_.jsx(k21,{children:_.jsx("a",{href:l.document_metadata.card.url,target:"_blank",children:_.jsx(ua,{variant:"outline",children:l.document_metadata.card.call_to_action_text??t("sourceCallToActionLabel")})})})]},l.id))}):_.jsx(_.Fragment,{})},md2=({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(Ui,{variant:t,layout:n,isLoading:l,className:"max-w-[95%]",children:_.jsx("img",{src:a.url,alt:a.filename})}),D21={markdown:cd2,text:({block:a,variant:t,layout:n,isLoading:l})=>_.jsx(Ui,{variant:t,layout:n,isLoading:l,className:"prose max-w-[60%]",children:_.jsx("p",{children:a.text})}),button:M0.Fragment,button_group:Gm2,source_group:sd2,image_reference:md2,conversation_rating:M0.Fragment},ud2=a=>a in D21,P21=(a,t,n)=>{const l=D21[a.type];return typeof l<"u"?M0.createElement(l,{key:`block-${a.id}`,variant:t,layout:n,block:a}):(console.warn(`No component found for block type: ${a.type}`),null)};function hd2({message:a,handleActionEvent:t,close:n}){return _.jsxs(Zd,{className:"sm:max-w-[425px]",children:[_.jsxs(wu0,{children:[_.jsx(yu0,{children:"Thank you for your response!"}),_.jsx(MQ0,{children:"Can you tell us what went wrong?"})]}),_.jsx(pd2,{message:a,handleActionEvent:t,close:n})]})}function dd2({message:a,handleActionEvent:t,close:n}){const{t:l}=Le(["common","feedback"]),[o,i]=e.useState(""),[s,u]=e.useState(!1),[A,p]=e.useState(!1),g=V=>{V.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),p(!0),setTimeout(()=>{u(!1),setTimeout(n,1500)},1500)};return _.jsxs(Ed,{className:"min-h-40 overflow-hidden rounded-t-[20px] border-primary bg-primary text-primary-foreground",children:[_.jsx(T7,{children:_.jsx(nl.div,{layoutId:"underline",children:_.jsx(Vd,{className:"",children:A?_.jsx(mJ0,{title:l("feedback:modalSubmittedTitle"),description:l("feedback:modalSubmittedDescription")}):_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("div",{className:"relative w-12"}),_.jsxs("div",{className:"text-center",children:[_.jsx(di,{className:"text-center",children:l("feedback:modalTitle")}),_.jsx(Nu0,{className:"text-primary-foreground/80",children:l("feedback:modalDescription")})]}),_.jsx(xu0,{className:"w-12",asChild:!0,children:_.jsx(ua,{variant:"link",onClick:n,className:"text-right text-primary-foreground",children:_.jsx(Xn,{weight:"regular",size:20})})})]})})})}),A?_.jsx(_.Fragment,{}):_.jsxs(nl.form,{onSubmit:g,className:"mt-auto flex flex-col gap-2 p-4 pt-2",children:[_.jsx(bd,{className:"border border-white text-base text-white shadow-none ring-0 placeholder:text-white focus-visible:ring-0 widget:text-sm",placeholder:l("feedback:modalPlaceholder"),"data-testid":"feedback-form-textarea",value:o,rows:4,disabled:s,onChange:V=>i(V.target.value)}),_.jsx(ua,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:l(s?"sending":"send")})]})]})}const Ad2=({message:a,handleActionEvent:t})=>{const{t:n}=Le("common"),{openModal:l,closeModal:o}=BQ0(),i=ou0("(min-width: 768px)"),{state:s}=we(),u=A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"negative"}),i&&!s.inShadowDom?l(Y7.Dialog,_.jsx(hd2,{message:a,handleActionEvent:t,close:o})):l(Y7.Drawer,_.jsx(dd2,{message:a,handleActionEvent:t,close:o}))};return _.jsxs("div",{className:"flex justify-start space-x-3",children:[_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="positive"?"text-green-500":"text-primary"}`,"data-testid":`thumbs-up thumbs-feedback-sentiment-${a.user_feedback_value==="positive"?a.user_feedback_value:"none"}`,onClick:A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"positive"})},children:[_.jsx(RG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="positive"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsUp")})]}),_.jsxs("button",{className:`flex h-auto items-center space-x-1 p-0 text-xs underline-offset-4 hover:underline disabled:pointer-events-none disabled:opacity-50 ${a.user_feedback_value==="negative"?"text-red-500":"text-primary"}`,"data-testid":`thumbs-down thumbs-feedback-sentiment-${a.user_feedback_value==="negative"?a.user_feedback_value:"none"}`,onClick:u,children:[_.jsx(SG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="negative"?"fill":"regular",size:20})," ",_.jsx("span",{children:n("feedback:thumbsDown")})]})]})},pd2=({message:a,handleActionEvent:t,close:n,className:l})=>{const[o,i]=e.useState(""),[s,u]=e.useState(!1),A=p=>{p.preventDefault(),u(!0),t("user-feedback-message",{id:a.id,value:o},"input"),i(""),setTimeout(()=>{u(!1),n()},500)};return _.jsxs("form",{"data-testid":"feedback-form",onSubmit:A,className:q2("mt-auto flex flex-col gap-2",l),children:[_.jsx(bd,{className:"border-0 bg-white text-base text-black shadow-none ring-0 focus-visible:ring-0 widget:text-sm",placeholder:"Share your thoughts here..",value:o,disabled:s,"data-testid":"feedback-form-textarea",onChange:p=>i(p.target.value)}),_.jsx(ua,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",className:"bg-primary-foreground text-primary hover:bg-primary-foreground/80",children:"Send"})]})},fd2=({message:a,index:t,isLast:n,isLastInGroup:l,isFirstInGroup:o,...i})=>{var C;const{state:s,handleActionEvent:u}=we(),{messages:A,userId:p}=s,g=t===A.length-1,V=p?hc(a,p):!1,v=V?"sent":"received",L=V?"default":"ai";return _.jsx("div",{...i,children:_.jsxs(ed0,{settings:s.settings,testId:t.toString(),variant:v,isFirstInGroup:o,isLastInGroup:l,sentAt:g?a.sent_at:null,userName:a.sender_name?a.sender_name:(C=s.settings)==null?void 0:C.digitalEmployeeName,className:"",children:[a.blocks.map(I=>P21(I,v,L)),a.request_user_feedback&&!V&&_.jsx(Ad2,{message:a,handleActionEvent:u})]})})},Zd2=()=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("div",{className:"bubble1 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble2 h-2 w-2 rounded-full"}),_.jsx("div",{className:"bubble3 h-2 w-2 rounded-full"})]}),Hd2=()=>{var t;const{state:a}=we();return _.jsx(ed0,{settings:a.settings,userName:(t=a.settings)==null?void 0:t.digitalEmployeeName,testId:"loading",variant:"received",isFirstInGroup:!0,isLastInGroup:!1,sentAt:null,className:"",children:_.jsx(Ui,{variant:"received",layout:"ai",className:"prose max-w-[60%]",children:_.jsx(Zd2,{})})},"message-loading")},gd2=150,Ed2=a=>{const[t,n]=e.useState(!1),l=e.useCallback(()=>{if(!a)return;const{scrollTop:i,scrollHeight:s,clientHeight:u}=a,A=s-i-u;n(A>gd2)},[a]);return e.useEffect(()=>{if(a)return l(),a.addEventListener("scroll",l),()=>{a.removeEventListener("scroll",l)}},[a,l]),{scrollToBottom:()=>{a==null||a.scrollTo({top:a.scrollHeight,behavior:"smooth"})},isScrolledUp:t}},Vd2=()=>{var o;const{t:a}=Le(),{state:t}=we(),n=e.useMemo(()=>{const i=u=>u.type==="text"||u.type==="markdown",s=t.messages.filter(u=>!hc(u,t.userId)&&u.type==="message"&&u.blocks.some(i)).slice(-1)[0];return(s==null?void 0:s.blocks.filter(i))??[]},[t.messages,t.userId]),l=`${((o=t.settings)==null?void 0:o.title)??a("common:bot")} ${a("header:typing")}`;return _.jsx("div",{className:"sr-only","aria-live":"polite",children:t.isTyping?l:n.map(i=>P21(i,"sent","default"))})};function Md2(a){return a?a.map(t=>({...t,blocks:t.blocks?t.blocks.filter(n=>ud2(n.type)):[]})):[]}function vd2(a){return a?a.filter(t=>t.blocks&&t.blocks.length>0):[]}const Ld2=({href:a="",children:t,...n})=>_.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...n,children:t}),wd2=68;function yd2(){var L,C,I,T,N;const a=e.useRef(null),{state:t,endDivRef:n,scrollableDivRef:l}=we(),{scrollToBottom:o,isScrolledUp:i}=Ed2(l.current),[s,u]=e.useState(!1),A=e.useMemo(()=>{const D=Md2(t.messages);return vd2(D)},[t.messages]),p=e.useMemo(()=>A.length>0&&hc(A[A.length-1],t.userId),[A,t.userId]);e.useEffect(()=>{t.isWaitingOnFirstStream&&setTimeout(()=>{var D;(D=l.current)==null||D.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})},100)},[t.isWaitingOnFirstStream]),e.useEffect(()=>{!s&&t.messages.length>0&&(u(!0),setTimeout(()=>{var D,B;(B=l.current)==null||B.scrollTo({top:(D=l.current)==null?void 0:D.scrollHeight})},0))},[t.messages,s]);const g=((L=l.current)==null?void 0:L.clientHeight)||0,V=wd2+(((C=a.current)==null?void 0:C.clientHeight)||0),v=`${g-V}px`;return _.jsxs("div",{className:"relative h-full w-full",children:[_.jsx(Vd2,{}),_.jsxs("div",{className:"flex h-full w-full flex-col overflow-y-auto",ref:l,children:[_.jsxs("div",{className:"flex grow flex-col gap-3 px-4 py-2",children:[((I=t.settings)==null?void 0:I.disclaimer)&&_.jsx("div",{children:_.jsx(O01,{rehypePlugins:[a21],className:"!m-0 max-w-none text-center text-[10px] leading-[14px] text-gray-500",skipHtml:!0,components:{a:Ld2},children:(T=t.settings)==null?void 0:T.disclaimer})}),A.map((D,B)=>{const q=B===A.length-1,G=A[B+1],z=A[B-1],X=G?D.sender_id!==G.sender_id:!0,J=z?D.sender_id!==z.sender_id:!0;return _.jsx(fd2,{message:D,index:B,isLast:q,isLastInGroup:X,isFirstInGroup:J,style:{minHeight:q&&t.hasSentMessageThisSession&&!p?v:void 0}},`message-${D.id}-${B}`)}),p&&_.jsx("div",{style:{minHeight:t.hasSentMessageThisSession?v:void 0},children:t.isTyping&&_.jsx(Hd2,{})})]}),((N=t.settings)==null?void 0:N.showFreedayBranding)&&_.jsx(ku0,{ref:a,name:"Freeday",site:"https://freeday.ai",className:"shrink-0 pb-4 pt-8"})]}),_.jsx("div",{ref:n}),i&&_.jsx(ua,{variant:"outline",size:"icon",onClick:o,className:"absolute bottom-2 left-1/2 -translate-x-1/2 border border-border p-1",children:_.jsx(Ah,{size:18})})]})}const Fd2=()=>{var u,A,p,g;const{state:a}=we(),{t}=Le(),[n,l]=e.useState(!0),[o,i]=e.useState(!1);e.useEffect(()=>{const V=setTimeout(()=>{i(!0)},300);return()=>clearTimeout(V)},[]),e.useEffect(()=>{if(!n)return;const V=v=>{!o||v.target.closest('[data-testid="chat-button"]')||l(!1)};return window.addEventListener("click",V),window.addEventListener("touchstart",V),()=>{window.removeEventListener("click",V),window.removeEventListener("touchstart",V)}},[o,n]);const s=()=>{l(!1)};return(u=a.settings)!=null&&u.bannerTitle&&n?_.jsx("div",{className:"pb-7.5 absolute left-0 right-0 top-0 max-h-[500px] -translate-y-full gap-4 overflow-hidden rounded-t-[30px] bg-white transition-all duration-300 ease-in-out","data-testid":"banner",children:_.jsxs("div",{className:"flex h-full w-full flex-col justify-center rounded-t-[30px] bg-primary/10 p-6",children:[_.jsx("button",{onClick:s,className:"absolute right-8 top-8 flex -translate-y-1/2 translate-x-1/2 cursor-pointer rounded p-1 hover:bg-primary/10 focus:outline-none focus:ring-2 focus:ring-primary","aria-label":t("common:closeNotification"),"data-testid":"close-button",children:_.jsx(Xn,{weight:"regular",size:20,className:"text-primary"})}),_.jsx("p",{className:"text-sm font-semibold text-primary",children:(A=a.settings)==null?void 0:A.bannerTitle}),((p=a.settings)==null?void 0:p.bannerMessage)&&_.jsx("p",{className:"whitespace-pre-line text-sm",children:(g=a.settings)==null?void 0:g.bannerMessage})]})}):null},Cd2=({placeholder:a,isTyping:t,onSendMessage:n})=>{const{t:l}=Le(),[o,i]=e.useState(""),[s,u]=e.useState(!0),A=e.useRef(null),p=L=>{i(L.target.value)};e.useEffect(()=>{u(o.trim().length===0||t)},[o,t]);const g=L=>{L==null||L.preventDefault(),!s&&(n(o),i(""))},V=L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),g(L))},v=()=>q2("absolute right-2 top-1/2 flex h-9 w-9 -translate-y-1/2 transform items-center justify-center rounded p-0 transition-all duration-0 ease-in-out",o.trim().length>0?"text-primary":"text-gray-300");return _.jsx("footer",{className:"relative bottom-0 left-0 right-0 border-t border-gray-200 bg-white",children:_.jsxs("div",{className:"p-4",children:[_.jsx(Fd2,{}),_.jsx("form",{onSubmit:g,children:_.jsx("div",{className:"flex w-full max-w-full items-center space-x-2",children:_.jsxs("div",{className:"relative w-full flex-1",ref:A,children:[_.jsxs("div",{className:"invisible max-h-[164px] min-h-[44px] overflow-y-hidden whitespace-pre-wrap break-words px-4 py-2",children:[o||a,"|"]}),_.jsx("label",{htmlFor:"chat-input-textarea",className:"sr-only",children:a}),_.jsx("textarea",{id:"chat-input-textarea",className:"absolute inset-0 resize-none rounded-3xl border border-gray-300 pb-[0px] pl-[16px] pr-[48px] pt-[10px] text-[16px] leading-[20px] placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-primary",placeholder:a,wrap:"hard","data-testid":"text-input-field",value:o,onKeyDown:V,onChange:p,rows:1}),t?_.jsx("div",{"data-testid":"stop-button",className:v(),children:_.jsx($h,{weight:"bold",className:"h-6 w-6"})}):_.jsx("button",{"data-testid":"send-button",className:v(),"aria-label":l("common:send"),children:_.jsx(zc,{weight:"fill",className:"h-6 w-6"})})]})})})]})})},bd2=()=>{var l,o;const{t:a}=Le(["common","footer"]),{sendNewMessage:t,state:n}=we();return _.jsxs(_.Fragment,{children:[((l=n.settings)==null?void 0:l.theme)!=="slim"&&_.jsx(Wr2,{}),_.jsx(w52,{position:"top-center",expand:!0,pauseWhenPageIsHidden:!0,richColors:!0}),_.jsx("main",{className:"flex-1 space-y-2 overflow-hidden bg-white",children:_.jsx(T7,{initial:!0,children:_.jsx(nl.div,{className:"h-full w-full",initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{duration:.3,ease:[.42,0,0,1],delay:.4},children:_.jsx(yd2,{})})})}),_.jsx(Cd2,{placeholder:a(((o=n.settings)==null?void 0:o.newMessagePlaceholder)??a("footer:newMessagePlaceholder")),isTyping:n.isTyping,onSendMessage:t})]})},Id2=a=>{const[t,n]=e.useState(null);return e.useEffect(()=>{if(!a)return;(async()=>{try{const i=await new qg0(a,new yH(kZ0())).fetchWidgetSettings();n(i)}catch(o){W6(o)}})()},[a]),{widgetSettings:t}},Sd2=(a=!1)=>{const[t,n]=e.useState(a),[l,o]=e.useState(!1);return e.useEffect(()=>{const i=s=>{s.type===x8.CLOSE?(n(!1),o(!0)):s.type===x8.OPEN&&(n(!0),o(!1))};return globalThis.addEventListener(x8.CLOSE,i),globalThis.addEventListener(x8.OPEN,i),()=>{globalThis.removeEventListener(x8.CLOSE,i),globalThis.removeEventListener(x8.OPEN,i)}},[]),{isWidgetOpen:t,setIsWidgetOpen:n,hideChatBarInput:l}},Rd2=a=>{const t=sE0();return{handleOpen:()=>{t.capture("widget:opened",{start_view:a==null?void 0:a.startView}),globalThis.dispatchEvent(new Event(x8.OPEN)),globalThis.postMessage({event:x8.START,payload:a},globalThis.location.origin)},handleOpenAndSendMessage:o=>{setTimeout(()=>{globalThis.postMessage({event:x8.START,payload:{suggestionMessage:o}},globalThis.location.origin),globalThis.dispatchEvent(new Event(x8.OPEN))},400)}}},Td2="https://cdn.jsdelivr.net/npm/@freeday-ai/webchat",xd2=()=>{e.useEffect(()=>{const a=n=>{O21(n.error)},t=n=>{O21(n.reason)};return globalThis.addEventListener("error",a),globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("error",a),globalThis.removeEventListener("unhandledrejection",t)}},[])},O21=a=>{var t;(t=a==null?void 0:a.stack)!=null&&t.includes(Td2)&&W6(a)};class Nd2 extends e.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){W6(t,"Uncaught rendering error",{componentStack:n.componentStack})}render(){return this.props.children}}const $d2=({channelId:a,metadata:t})=>{xd2();const{widgetSettings:n}=Id2(a);return!a||!n?null:_.jsx(Nd2,{children:_.jsx(Xr1,{config:{...n,metadata:t?JSON.parse(t):void 0},inShadowDom:!0,children:_.jsx(Dd2,{widgetSettings:{...n,metadata:t?JSON.parse(t):void 0}})})})};function kd2(){e.useEffect(()=>{if(!/Mobi|Android/i.test(navigator.userAgent))return;const t=document.querySelector(".widget-chat-container");if(!t)return;const n=()=>{t.style.height=`${window.innerHeight}px`};n(),window.addEventListener("resize",n);const l=t.querySelector("#chat-input-textarea"),o=i=>{setTimeout(n,50);const s=i.target;s&&setTimeout(()=>{s.scrollIntoView({behavior:"smooth",block:"center"})},300)};return l==null||l.addEventListener("focus",o),()=>{window.removeEventListener("resize",n),l==null||l.removeEventListener("focus",o),t.style.height=""}},[])}const Dd2=({widgetSettings:a})=>{const t=a.startView===F3.FULL_SCREEN,n=a.startView===F3.UNFOLDED_CHAT_VIEW,l=t||n,{isWidgetOpen:o,setIsWidgetOpen:i}=Sd2(l),{handleOpen:s,handleOpenAndSendMessage:u}=Rd2(a);return kd2(),e.useEffect(()=>{if(!l)return;i(!0);const A=requestAnimationFrame(s);return()=>cancelAnimationFrame(A)},[]),_.jsxs(_.Fragment,{children:[_.jsx(T7,{children:o&&_.jsx(nl.div,{className:q2("chat-window-renderer",{"full-screen":t}),"data-testid":"chat-window-renderer",initial:{opacity:0,y:30},animate:{opacity:1,y:0,transition:{delay:.2}},exit:{opacity:0,y:30},transition:{duration:.35,ease:[.42,0,0,1]},transformTemplate:t?(A,p)=>`translateX(-50%) ${p}`:void 0,children:_.jsx(nr2,{children:_.jsx("div",{className:"widget-chat-container flex flex-col",children:_.jsx(bd2,{})})})})}),!t&&_.jsx(T7,{children:!o&&_.jsx(nl.div,{className:"button-container",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1,transition:{delay:.3}},exit:{opacity:0,scale:0},transition:{duration:.3,ease:[.42,0,0,1]},children:_.jsx(z32,{onOpen:s,onSendMessage:u})})})]})};B41("freeday-widget",$d2,["channelId","metadata"]);const _21=a=>{const{channelId:t,metadata:n}=a,l=document.createElement("div"),o=document.createElement("freeday-widget");o.setAttribute("channelId",t),n&&o.setAttribute("metadata",JSON.stringify(n)),l.appendChild(o),document.body?document.body.appendChild(l):window.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(l)})};return window.FreedayWidget={bootstrap:_21},Xf.bootstrap=_21,Object.defineProperty(Xf,Symbol.toStringTag,{value:"Module"}),Xf})({});
|
package/dist/webchat.mjs
CHANGED
|
@@ -117280,6 +117280,7 @@ function Ug2() {
|
|
|
117280
117280
|
const l = t.querySelector(
|
|
117281
117281
|
"#chat-input-textarea"
|
|
117282
117282
|
), o = (i) => {
|
|
117283
|
+
setTimeout(n, 50);
|
|
117283
117284
|
const s = i.target;
|
|
117284
117285
|
s && setTimeout(() => {
|
|
117285
117286
|
s.scrollIntoView({ behavior: "smooth", block: "center" });
|