@freeday-ai/webchat 2025.11.1-4.7.49.9030 → 2025.11.1-4.8.30.6191

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.
@@ -328,4 +328,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
328
328
  `))+1))}const s="#".repeat(o),u=n.enter("headingAtx"),A=n.enter("phrasing");i.move(s+" ");let p=n.containerPhrasing(a,{before:"# ",after:`
329
329
  `,...i.current()});return/^[\t ]/.test(p)&&(p=Ki(p.charCodeAt(0))+p.slice(1)),p=p?s+" "+p:s,n.options.closeAtx&&(p+=" "+s),A(),u(),p}p21.peek=ch2;function p21(a){return a.value||""}function ch2(){return"<"}f21.peek=ih2;function f21(a,t,n,l){const o=ad0(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 ih2(){return"!"}Z21.peek=sh2;function Z21(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 sh2(){return"!"}H21.peek=mh2;function H21(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 mh2(){return"`"}function g21(a,t){const n=mh0(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))}E21.peek=uh2;function E21(a,t,n,l){const o=ad0(n),i=o==='"'?"Quote":"Apostrophe",s=n.createTracker(l);let u,A;if(g21(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 uh2(a,t,n){return g21(a,n)?"<":"["}V21.peek=hh2;function V21(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 hh2(){return"["}function td0(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 dh2(a){const t=td0(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 Ah2(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 M21(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 ph2(a,t,n,l){const o=n.enter("list"),i=n.bulletCurrent;let s=a.ordered?Ah2(n):td0(n);const u=a.ordered?s==="."?")":".":dh2(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),M21(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 fh2(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 Zh2(a,t,n,l){const o=fh2(n);let i=n.bulletCurrent||td0(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 Hh2(a,t,n,l){const o=n.enter("paragraph"),i=n.enter("phrasing"),s=n.containerPhrasing(a,l);return i(),o(),s}const gh2=Kd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Eh2(a,t,n,l){return(a.children.some(function(s){return gh2(s)})?n.containerPhrasing:n.containerFlow).call(n,a,l)}function Vh2(a){const t=a.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}v21.peek=Mh2;function v21(a,t,n,l){const o=Vh2(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=mA(l.before.charCodeAt(l.before.length-1),p,o);g.inside&&(A=Ki(p)+A.slice(1));const V=A.charCodeAt(A.length-1),v=mA(l.after.charCodeAt(0),V,o);v.inside&&(A=A.slice(0,-1)+Ki(V));const L=s.move(o+o);return i(),n.attentionEncodeSurroundingInfo={after:v.outside,before:g.outside},u+A+L}function Mh2(a,t,n){return n.options.strong||"*"}function vh2(a,t,n,l){return n.safe(a.value,l)}function Lh2(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 wh2(a,t,n){const l=(M21(n)+(n.options.ruleSpaces?" ":"")).repeat(Lh2(n));return n.options.ruleSpaces?l.slice(0,-1):l}const L21={blockquote:Gu2,break:d21,code:eh2,definition:th2,emphasis:A21,hardBreak:d21,heading:oh2,html:p21,image:f21,imageReference:Z21,inlineCode:H21,link:E21,linkReference:V21,list:ph2,listItem:Zh2,paragraph:Hh2,root:Eh2,strong:v21,text:vh2,thematicBreak:wh2};function yh2(){return{enter:{table:Fh2,tableData:w21,tableHeader:w21,tableRow:bh2},exit:{codeText:Ih2,table:Ch2,tableData:nd0,tableHeader:nd0,tableRow:nd0}}}function Fh2(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 Ch2(a){this.exit(a),this.data.inTable=void 0}function bh2(a){this.enter({type:"tableRow",children:[]},a)}function nd0(a){this.exit(a)}function w21(a){this.enter({type:"tableCell",children:[]},a)}function Ih2(a){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Sh2));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(a)}function Sh2(a,t){return t==="|"?t:a}function Rh2(a){const t=a||{},n=t.tableCellPadding,l=t.tablePipeAlign,o=t.stringLength,i=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
330
330
  `,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,x){return p(g(L,I,x),L.align)}function u(L,C,I,x){const N=V(L,I,x),O=p([N]);return O.slice(0,O.indexOf(`
331
- `))}function A(L,C,I,x){const N=I.enter("tableCell"),O=I.enter("phrasing"),B=I.containerPhrasing(L,{...x,before:i,after:i});return O(),N(),B}function p(L,C){return qu2(L,{align:C,alignDelimiters:l,padding:n,stringLength:o})}function g(L,C,I){const x=L.children;let N=-1;const O=[],B=C.enter("table");for(;++N<x.length;)O[N]=V(x[N],C,I);return B(),O}function V(L,C,I){const x=L.children;let N=-1;const O=[],B=C.enter("tableRow");for(;++N<x.length;)O[N]=A(x[N],L,C,I);return B(),O}function v(L,C,I){let x=L21.inlineCode(L,C,I);return I.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function xh2(){return{exit:{taskListCheckValueChecked:y21,taskListCheckValueUnchecked:y21,paragraph:Nh2}}}function Th2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$h2}}}function y21(a){const t=this.stack[this.stack.length-2];t.type,t.checked=a.type==="taskListCheckValueChecked"}function Nh2(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 $h2(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=L21.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 kh2(){return[pu2(),$u2(),Ou2(),yh2(),xh2()]}function Dh2(a){return{extensions:[fu2(),ku2(a),_u2(),Rh2(a),Th2()]}}const Ph2={tokenize:jh2,partial:!0},F21={tokenize:qh2,partial:!0},C21={tokenize:Wh2,partial:!0},b21={tokenize:Gh2,partial:!0},Oh2={tokenize:Yh2,partial:!0},I21={name:"wwwAutolink",tokenize:Uh2,previous:R21},S21={name:"protocolAutolink",tokenize:zh2,previous:x21},j3={name:"emailAutolink",tokenize:Bh2,previous:T21},Ut={};function _h2(){return{text:Ut}}let Wr=48;for(;Wr<123;)Ut[Wr]=j3,Wr++,Wr===58?Wr=65:Wr===91&&(Wr=97);Ut[43]=j3,Ut[45]=j3,Ut[46]=j3,Ut[95]=j3,Ut[72]=[j3,S21],Ut[104]=[j3,S21],Ut[87]=[j3,I21],Ut[119]=[j3,I21];function Bh2(a,t,n){const l=this;let o,i;return s;function s(V){return!ld0(V)||!T21.call(l,l.previous)||rd0(l.events)?n(V):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),u(V))}function u(V){return ld0(V)?(a.consume(V),u):V===64?(a.consume(V),A):n(V)}function A(V){return V===46?a.check(Oh2,g,p)(V):V===45||V===95||I6(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&&J6(l.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),t(V)):n(V)}}function Uh2(a,t,n){const l=this;return o;function o(s){return s!==87&&s!==119||!R21.call(l,l.previous)||rd0(l.events)?n(s):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(Ph2,a.attempt(F21,a.attempt(C21,i),n),n)(s))}function i(s){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),t(s)}}function zh2(a,t,n){const l=this;let o="",i=!1;return s;function s(V){return(V===72||V===104)&&x21.call(l,l.previous)&&!rd0(l.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),o+=String.fromCodePoint(V),a.consume(V),u):n(V)}function u(V){if(J6(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||Bd(V)||M8(V)||Br(V)||Ud(V)?n(V):a.attempt(F21,a.attempt(C21,g),n)(V)}function g(V){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),t(V)}}function jh2(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 qh2(a,t,n){let l,o,i;return s;function s(p){return p===46||p===95?a.check(b21,A,u)(p):p===null||M8(p)||Br(p)||p!==45&&Ud(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 Wh2(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(b21,t,i)(s):s===null||M8(s)||Br(s)?t(s):(a.consume(s),o)}function i(s){return s===41&&l++,a.consume(s),o}}function Gh2(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)||Br(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||M8(u)||Br(u)?t(u):l(u)}function i(u){return J6(u)?s(u):n(u)}function s(u){return u===59?(a.consume(u),l):J6(u)?(a.consume(u),s):n(u)}}function Yh2(a,t,n){return l;function l(i){return a.consume(i),o}function o(i){return I6(i)?n(i):t(i)}}function R21(a){return a===null||a===40||a===42||a===95||a===91||a===93||a===126||M8(a)}function x21(a){return!J6(a)}function T21(a){return!(a===47||ld0(a))}function ld0(a){return a===43||a===45||a===46||a===95||I6(a)}function rd0(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 Kh2={tokenize:ld2,partial:!0};function Xh2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ad2,continuation:{tokenize:td2},exit:nd2}},text:{91:{name:"gfmFootnoteCall",tokenize:ed2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Qh2,resolveTo:Jh2}}}}function Qh2(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=Ka(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 Jh2(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 ed2(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(Ka(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 ad2(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=Ka(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),G2(a,L,"gfmFootnoteDefinitionWhitespace")):n(C)}function L(C){return t(C)}}function td2(a,t,n){return a.check(Ri,t,a.attempt(Kh2,t,n))}function nd2(a){a.exit("gfmFootnoteDefinition")}function ld2(a,t,n){const l=this;return G2(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 rd2(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&&Y4(v,v.length,0,zd(L,s.slice(p+1,A),u)),Y4(v,v.length,0,[["exit",V,u],["enter",s[A][1],u],["exit",s[A][1],u],["exit",g,u]]),Y4(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=o9(p);if(C===126)return V>1?A(C):(s.consume(C),V++,L);if(V<2&&!n)return A(C);const x=s.exit("strikethroughSequenceTemporary"),N=o9(C);return x._open=!N||N===2&&!!I,x._close=!I||I===2&&!!N,u(C)}}}class od2{constructor(){this.map=[]}add(t,n,l){cd2(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 cd2(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 id2(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 sd2(){return{flow:{null:{name:"table",tokenize:md2,resolveAll:ud2}}}}function md2(a,t,n){const l=this;let o=0,i=0,s;return u;function u(Q){let Z0=l.events.length-1;for(;Z0>-1;){const a0=l.events[Z0][1].type;if(a0==="lineEnding"||a0==="linePrefix")Z0--;else break}const c0=Z0>-1?l.events[Z0][1].type:null,l0=c0==="tableHead"||c0==="tableRow"?q:A;return l0===q&&l.parser.lazy[l.now().line]?n(Q):l0(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):X1(Q)?i>1?(i=0,l.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(Q),a.exit("lineEnding"),L):n(Q):P2(Q)?G2(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,P2(Q)?G2(a,C,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):C(Q))}function C(Q){return Q===45||Q===58?x(Q):Q===124?(s=!0,a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),I):Y(Q)}function I(Q){return P2(Q)?G2(a,x,"whitespace")(Q):x(Q)}function x(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||X1(Q)?j(Q):Y(Q)}function N(Q){return Q===45?(a.enter("tableDelimiterFiller"),O(Q)):Y(Q)}function O(Q){return Q===45?(a.consume(Q),O):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 P2(Q)?G2(a,j,"whitespace")(Q):j(Q)}function j(Q){return Q===124?C(Q):Q===null||X1(Q)?!s||o!==i?Y(Q):(a.exit("tableDelimiterRow"),a.exit("tableHead"),t(Q)):Y(Q)}function Y(Q){return n(Q)}function q(Q){return a.enter("tableRow"),G(Q)}function G(Q){return Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),G):Q===null||X1(Q)?(a.exit("tableRow"),t(Q)):P2(Q)?G2(a,G,"whitespace")(Q):(a.enter("data"),J(Q))}function J(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),G(Q)):(a.consume(Q),Q===92?f0:J)}function f0(Q){return Q===92||Q===124?(a.consume(Q),J):J(Q)}}function ud2(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 od2;for(;++n<a.length;){const L=a[n],C=L[1];L[0]==="enter"?C.type==="tableHead"?(u=!1,A!==0&&(N21(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=uA(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=uA(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=uA(v,t,i,o,n,V)):s[1]!==0&&(V=uA(v,t,s,o,n,V)),o=0):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(s[3]=n)}for(A!==0&&N21(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=id2(t.events,n))}return a}function uA(a,t,n,l,o,i){const s=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(i.end=Object.assign({},f9(t.events,n[0])),a.add(n[0],0,[["exit",i,t]]));const A=f9(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=f9(t.events,n[2]),g=f9(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({},f9(t.events,o)),a.add(o,0,[["exit",i,t]]),i=void 0),i}function N21(a,t,n,l,o){const i=[],s=f9(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 f9(a,t){const n=a[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const hd2={name:"tasklistCheck",tokenize:Ad2};function dd2(){return{text:{91:hd2}}}function Ad2(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 X1(A)?t(A):P2(A)?a.check({tokenize:pd2},t,n)(A):n(A)}}function pd2(a,t,n){return G2(a,l,"whitespace");function l(o){return o===null?n(o):t(o)}}function fd2(a){return e01([_h2(),Xh2(),rd2(a),sd2(),dd2()])}const Zd2={};function Hd2(a){const t=this,n=a||Zd2,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),i=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(fd2(n)),i.push(kh2()),s.push(Dh2(n))}const gd2=Bu0("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"}}),od0=e.forwardRef(({settings:a,className:t,variant:n,isLastInGroup:l,isFirstInGroup:o,sentAt:i,layout:s,children:u,testId:A="",userName:p,...g},V)=>D.jsxs("div",{"data-testid":n=="received"?`chat-message-${A} incoming-message-${A}`:`chat-message-${A} outgoing-message-${A}`,children:[n&&o&&Vd2({variant:n,settings:a,userName:p}),D.jsx("div",{className:W2(gd2({variant:n,layout:s,isLastInGroup:l,className:t}),a!=null&&a.avatar?"pl-6":""),ref:V,...g,children:u})]}));od0.displayName="Message";const Ed2=Bu0("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"}}),Z9=e.forwardRef(({className:a,variant:t,layout:n,isLoading:l=!1,children:o,...i},s)=>D.jsx("div",{className:W2(Ed2({variant:t,layout:n,isLoading:l,className:a}),"overflow-x-auto break-words"),ref:s,...i,children:o}));Z9.displayName="MessageBubble";const Vd2=({variant:a,settings:t,userName:n})=>a!=="received"?null:D.jsxs("div",{className:"mb-1 flex items-center justify-start space-x-1",children:[(t==null?void 0:t.avatar)&&D.jsx("img",{width:48,height:48,className:"mt-1 h-5 w-5 rounded-full",src:t.avatar,alt:"Avatar"}),n&&D.jsx("span",{className:"font-brand text-[11.2px] font-bold leading-[16.8px] text-primary",children:n})]}),Md2=({block:a,variant:t,layout:n,isLoading:l})=>D.jsx(Z9,{variant:t,layout:n,isLoading:l,className:"prose max-w-[95%] break-words prose-a:text-blue-600",children:D.jsx(z01,{rehypePlugins:[r21],remarkPlugins:[Hd2],components:{a:vd2},className:"",skipHtml:!0,children:a.content})});function vd2(a){return D.jsx("a",{href:a.href,target:"_blank",children:a.children})}const $21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));$21.displayName="Card";const k21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("flex flex-col space-y-1.5 p-6",a),...t}));k21.displayName="CardHeader";const D21=e.forwardRef(({className:a,...t},n)=>D.jsx("h3",{ref:n,className:W2("text-2xl font-semibold leading-none tracking-tight",a),...t}));D21.displayName="CardTitle";const P21=e.forwardRef(({className:a,...t},n)=>D.jsx("p",{ref:n,className:W2("text-sm text-muted-foreground",a),...t}));P21.displayName="CardDescription";const O21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("p-6 pt-0",a),...t}));O21.displayName="CardContent";const _21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("flex items-center p-6 pt-0",a),...t}));_21.displayName="CardFooter";const Ld2=({block:a})=>{const{t}=Ee("common");return a.sources.some(l=>l.document_metadata&&l.document_metadata.card)?D.jsx("div",{className:"flex w-full max-w-full gap-5 overflow-x-auto",children:a.sources.map(l=>D.jsxs($21,{"data-url":l.source_link,className:"min-w-[200px] max-w-72 overflow-hidden",children:[D.jsx(k21,{className:"h-full max-h-[120px] p-0",children:D.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})}),D.jsxs(O21,{className:"p-4",children:[D.jsx(D21,{className:"text-md line-clamp-1 font-bold",children:l.document_metadata.card.title}),l.document_metadata.card.description&&D.jsx(P21,{className:"line-clamp-2 text-sm",children:l.document_metadata.card.description})]}),D.jsx(_21,{children:D.jsx("a",{href:l.document_metadata.card.url,target:"_blank",children:D.jsx(H4,{variant:"outline",children:l.document_metadata.card.call_to_action_text??t("sourceCallToActionLabel")})})})]},l.id))}):D.jsx(D.Fragment,{})},wd2=({block:a,variant:t,layout:n,isLoading:l})=>D.jsx(Z9,{variant:t,layout:n,isLoading:l,className:"max-w-[95%]",children:D.jsx("img",{src:a.url,alt:a.filename})}),B21={markdown:Md2,text:({block:a,variant:t,layout:n,isLoading:l})=>D.jsx(Z9,{variant:t,layout:n,isLoading:l,className:"prose max-w-[60%]",children:D.jsx("p",{children:a.text})}),button:V0.Fragment,button_group:_52,source_group:Ld2,image_reference:wd2},yd2=a=>a in B21,U21=(a,t,n)=>{const l=B21[a.type];return l!==void 0?V0.createElement(l,{key:`block-${a.id}`,variant:t,layout:n,block:a}):(console.warn(`No component found for block type: ${a.type}`),null)},Fd2=150,Cd2=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>Fd2)},[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}},bd2=()=>{var o;const{t:a}=Ee(),{state:t}=Ve(),n=e.useMemo(()=>{const i=u=>u.type==="text"||u.type==="markdown",s=t.messages.filter(u=>!E7(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 D.jsx("div",{className:"sr-only","aria-live":"polite",children:t.isTyping?l:n.map(i=>U21(i,"sent","default"))})},Id2=({messages:a})=>{const{state:t}=Ve(),{userId:n,isTyping:l,hasSentMessageThisSession:o}=t,{hasUploadState:i}=Gc(),s=e.useMemo(()=>{const A=[...Sd2(a)],p=a.at(-1);return(p?E7(p,n):!1)&&l&&A.push({id:"typing-indicator",type:"typing-indicator"}),i&&A.push({id:"upload-bubble",type:"upload-bubble"}),xd2(A,n,o||i)},[a,n,l,o,i]),u=e.useMemo(()=>s.length,[s.length]);return{chatGroups:s,groupCount:u}},Sd2=a=>a.map((t,n)=>{const l=a[n+1],o=a[n-1];return{id:`message-${t.id}-${n}`,type:"message",message:t,index:n,isFirstInGroup:o?t.sender_id!==o.sender_id:!0,isLastInGroup:l?t.sender_id!==l.sender_id:!0}}),Rd2=(a,t)=>a.type==="message"&&E7(a.message,t)||a.type==="upload-bubble",xd2=(a,t,n)=>{const l=[];let o=[];for(const i of a)Rd2(i,t)&&o.length>0?(l.push({id:`group-${l.length}`,items:o,showPlaceholder:!1}),o=[i]):o.push(i);return o.length>0&&l.push({id:`group-${l.length}`,items:o,showPlaceholder:n}),l};function Td2({message:a,handleActionEvent:t,close:n}){return D.jsxs(Cd,{className:"sm:max-w-[425px]",children:[D.jsxs(Su0,{children:[D.jsx(Ru0,{children:"Thank you for your response!"}),D.jsx(yQ0,{children:"Can you tell us what went wrong?"})]}),D.jsx(kd2,{message:a,handleActionEvent:t,close:n})]})}function Nd2({message:a,handleActionEvent:t,close:n}){const{t:l}=Ee(["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 D.jsxs(Ei,{className:"min-h-40 overflow-hidden rounded-t-[20px] border-primary bg-primary text-primary-foreground",children:[D.jsx($7,{children:D.jsx(rl.div,{layoutId:"underline",children:D.jsx(Sd,{className:"",children:A?D.jsx(AJ0,{title:l("feedback:modalSubmittedTitle"),description:l("feedback:modalSubmittedDescription")}):D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsx("div",{className:"relative w-12"}),D.jsxs("div",{className:"text-center",children:[D.jsx(Q7,{className:"text-center",children:l("feedback:modalTitle")}),D.jsx(_u0,{className:"text-primary-foreground/80",children:l("feedback:modalDescription")})]}),D.jsx(Ou0,{className:"w-12",asChild:!0,children:D.jsx(H4,{variant:"link",onClick:n,className:"text-right text-primary-foreground",children:D.jsx(Jn,{weight:"regular",size:20})})})]})})})}),A?D.jsx(D.Fragment,{}):D.jsxs(rl.form,{onSubmit:g,className:"mt-auto flex flex-col gap-2 p-4 pt-2",children:[D.jsx($d,{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)}),D.jsx(H4,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",children:l(s?"sending":"send")})]})]})}const $d2=({message:a,handleActionEvent:t})=>{const{t:n}=Ee("common"),{openModal:l,closeModal:o}=Rd(),i=fd("(min-width: 768px)"),{state:s}=Ve(),u=A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"negative"}),i&&!s.inShadowDom?l(Pr.Dialog,D.jsx(Td2,{message:a,handleActionEvent:t,close:o})):l(Pr.Drawer,D.jsx(Nd2,{message:a,handleActionEvent:t,close:o}))};return D.jsxs("div",{className:"flex justify-start space-x-3",children:[D.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:[D.jsx($G0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="positive"?"fill":"regular",size:20})," ",D.jsx("span",{children:n("feedback:thumbsUp")})]}),D.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:[D.jsx(NG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="negative"?"fill":"regular",size:20})," ",D.jsx("span",{children:n("feedback:thumbsDown")})]})]})},kd2=({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 D.jsxs("form",{"data-testid":"feedback-form",onSubmit:A,className:W2("mt-auto flex flex-col gap-2",l),children:[D.jsx($d,{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)}),D.jsx(H4,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",children:"Send"})]})},Dd2=({message:a,index:t,isLastInGroup:n,isFirstInGroup:l,...o})=>{var L;const{state:i,handleActionEvent:s}=Ve(),{messages:u,userId:A}=i,p=t===u.length-1,g=A?E7(a,A):!1,V=g?"sent":"received",v=g?"default":"ai";return D.jsx("div",{...o,children:D.jsxs(od0,{settings:i.settings,testId:t.toString(),variant:V,isFirstInGroup:l,isLastInGroup:n,sentAt:p?a.sent_at:null,userName:a.sender_name?a.sender_name:(L=i.settings)==null?void 0:L.digitalEmployeeName,className:"",children:[a.blocks.map(C=>U21(C,V,v)),a.request_user_feedback&&!g&&D.jsx($d2,{message:a,handleActionEvent:s})]})})},Pd2=()=>D.jsxs("div",{className:"flex items-center gap-1",children:[D.jsx("div",{className:"bubble1 h-2 w-2 rounded-full"}),D.jsx("div",{className:"bubble2 h-2 w-2 rounded-full"}),D.jsx("div",{className:"bubble3 h-2 w-2 rounded-full"})]}),Od2=()=>{var t;const{state:a}=Ve();return D.jsx(od0,{settings:a.settings,userName:(t=a.settings)==null?void 0:t.digitalEmployeeName,testId:"loading",variant:"received",isFirstInGroup:!0,isLastInGroup:!1,sentAt:null,className:"",children:D.jsx(Z9,{variant:"received",layout:"ai",className:"prose max-w-[60%]",children:D.jsx(Pd2,{})})},"message-loading")},_d2={spinner:"_spinner_mxybw_1"},z21=({size:a=20,className:t=""})=>D.jsx("div",{className:`${_d2.spinner} ${t}`,style:{width:a,height:a},"aria-hidden":"true"}),w4={container:"_container_1e6ea_1",bubble:"_bubble_1e6ea_7",error:"_error_1e6ea_11",uploadingPlaceholder:"_uploadingPlaceholder_1e6ea_15",spinner:"_spinner_1e6ea_22",uploadingText:"_uploadingText_1e6ea_26",content:"_content_1e6ea_30",fileContainer:"_fileContainer_1e6ea_36",fileInfo:"_fileInfo_1e6ea_42",fileIcon:"_fileIcon_1e6ea_48",fileName:"_fileName_1e6ea_52",errorContainer:"_errorContainer_1e6ea_59",errorIcon:"_errorIcon_1e6ea_65",errorText:"_errorText_1e6ea_69"},Bd2=()=>{const{file:a,error:t}=Gc();return D.jsx("div",{className:w4.container,children:D.jsx(Z9,{variant:"sent",layout:"default",className:xZ(w4.bubble,{[w4.error]:!!t}),children:D.jsx("div",{className:w4.content,children:D.jsx(Ud2,{file:a,error:t})})})})},Ud2=({file:a,error:t})=>{const{t:n}=Ee(),l=e.useMemo(()=>a&&URL.createObjectURL(a),[a]);if(t)return D.jsxs("div",{className:w4.errorContainer,children:[D.jsx(Gh,{size:20,className:w4.errorIcon}),D.jsx("span",{className:w4.errorText,children:t})]});if(!a||!l)return D.jsxs("div",{className:w4.uploadingPlaceholder,children:[D.jsx(z21,{size:18,className:w4.spinner}),D.jsx("span",{className:w4.uploadingText,children:n("upload:uploadingText")})]});const o=()=>{URL.revokeObjectURL(l)};return D.jsxs("div",{className:w4.fileContainer,children:[D.jsx("img",{src:l,alt:a.name,onLoad:o}),D.jsxs("div",{className:w4.fileInfo,children:[D.jsx(Xc,{size:16,className:w4.fileIcon}),D.jsx("span",{className:w4.fileName,children:a==null?void 0:a.name})]})]})},zd2=({item:a})=>{switch(a.type){case"message":return D.jsx(Dd2,{message:a.message,index:a.index,isLastInGroup:a.isLastInGroup,isFirstInGroup:a.isFirstInGroup});case"typing-indicator":return D.jsx(Od2,{});case"upload-bubble":return D.jsx(Bd2,{});default:return null}},jd2=({group:a,placeholderMinHeight:t})=>D.jsx("div",{className:"flex flex-col gap-3",style:{minHeight:a.showPlaceholder?t:void 0},children:a.items.map(n=>D.jsx(zd2,{item:n},n.id))},a.id),qd2=({disclaimer:a})=>D.jsx("div",{children:D.jsx(z01,{rehypePlugins:[r21],className:"!m-0 max-w-none text-center text-[10px] leading-[14px] text-gray-500",skipHtml:!0,components:{a:Wd2},children:a})}),Wd2=({href:a="",children:t,...n})=>D.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...n,children:t});function Gd2(a){return a?a.map(t=>({...t,blocks:t.blocks?t.blocks.filter(n=>yd2(n.type)):[]})):[]}function Yd2(a){return a?a.filter(t=>t.blocks&&t.blocks.length>0):[]}const Kd2=16;function Xd2(){var C,I,x,N;const a=e.useRef(null),{state:t,endDivRef:n,scrollableDivRef:l}=Ve(),{scrollToBottom:o,isScrolledUp:i}=Cd2(l.current),[s,u]=e.useState(!1),A=e.useMemo(()=>{const O=Gd2(t.messages);return Yd2(O)},[t.messages]),{chatGroups:p,groupCount:g}=Id2({messages:A});e.useEffect(()=>{p.some(B=>B.showPlaceholder)&&l.current&&setTimeout(()=>{var B;(B=l.current)==null||B.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})},100)},[g,l]),e.useEffect(()=>{!s&&t.messages.length>0&&(u(!0),setTimeout(()=>{var O,B;(B=l.current)==null||B.scrollTo({top:(O=l.current)==null?void 0:O.scrollHeight})},0))},[t.messages,s]);const V=((C=l.current)==null?void 0:C.clientHeight)||0,v=Kd2+(((I=a.current)==null?void 0:I.clientHeight)||0),L=`${V-v}px`;return D.jsxs("div",{className:"relative h-full w-full",children:[D.jsx(bd2,{}),D.jsxs("div",{className:"flex h-full w-full flex-col overflow-y-auto",ref:l,children:[D.jsxs("div",{className:"flex grow flex-col gap-3 px-4 py-2",children:[((x=t.settings)==null?void 0:x.disclaimer)&&D.jsx(qd2,{disclaimer:t.settings.disclaimer}),p.map(O=>D.jsx(jd2,{group:O,placeholderMinHeight:L},O.id))]}),((N=t.settings)==null?void 0:N.showFreedayBranding)&&D.jsx(Uu0,{ref:a,name:"Freeday",site:"https://freeday.ai",className:"shrink-0 pb-4 pt-8"})]}),D.jsx("div",{ref:n}),i&&D.jsx(H4,{variant:"outline",size:"icon",onClick:o,className:"absolute bottom-2 left-1/2 -translate-x-1/2 border border-border p-1",children:D.jsx(vh,{size:18})})]})}const Qd2=()=>{var u,A,p,g;const{state:a}=Ve(),{t}=Ee(),[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?D.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:D.jsxs("div",{className:"flex h-full w-full flex-col justify-center rounded-t-[30px] bg-primary/10 p-6",children:[D.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:D.jsx(Jn,{weight:"regular",size:20,className:"text-primary"})}),D.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)&&D.jsx("p",{className:"whitespace-pre-line text-sm",children:(g=a.settings)==null?void 0:g.bannerMessage})]})}):null},j21=["image/jpeg","image/jpg","image/png","image/gif","image/webp"],Jd2=async(a,t=100)=>{const n=t*1024;if(a.size<=n)return a;let l=.9,o=a;for(;o.size>n&&l>.1;)o=await lA2(a,l),l-=.1;return o},eA2=(a,t,n=2048)=>a<=n&&t<=n?{width:a,height:t}:a>t?{width:n,height:t/a*n}:{width:a/t*n,height:n},aA2=a=>new Promise((t,n)=>{const l=new Image;l.onload=()=>t(l),l.onerror=()=>n(new Error("Failed to load image")),l.src=a}),tA2=a=>new Promise((t,n)=>{const l=new FileReader;l.onload=o=>{var i;return t((i=o.target)==null?void 0:i.result)},l.onerror=()=>n(new Error("Failed to read file")),l.readAsDataURL(a)}),nA2=(a,t,n,l)=>new Promise((o,i)=>{a.toBlob(s=>{if(!s){i(new Error("Failed to compress image"));return}const u=new File([s],t,{type:n,lastModified:Date.now()});o(u)},n,l)}),lA2=async(a,t)=>{const n=await tA2(a),l=await aA2(n),o=document.createElement("canvas"),i=eA2(l.width,l.height);o.width=i.width,o.height=i.height;const s=o.getContext("2d");if(!s)throw new Error("Failed to get canvas context");return s.drawImage(l,0,0,i.width,i.height),nA2(o,a.name,a.type,t)},q21=50,rA2=()=>{const{t:a}=Ee(),{setFile:t,setError:n,setIsLoading:l,clearUploadedFile:o}=Gc(),i=async A=>{n(null);const p=u(A);if(p){s(p),o();return}try{l(!0);const g=await Jd2(A,100);await new Promise(V=>setTimeout(V,2e3)),t(g)}catch(g){console.error("Error processing image:",g),s(a("upload:processingError"))}finally{l(!1)}},s=A=>{n(A),o()},u=A=>{if(!j21.includes(A.type))return a("upload:invalidFileType");const p=q21*1024*1024;if(A.size>p)return a("upload:fileSizeExceeded",{maxSize:q21})};return{uploadFile:i}},oA2=()=>{const{t:a}=Ee(),{fileInputRef:t,isLoading:n}=Gc(),{uploadFile:l}=rA2(),o=()=>{var s;(s=t.current)==null||s.click()},i=s=>{var A;const u=(A=s.target.files)==null?void 0:A[0];u&&l(u)};return D.jsxs(D.Fragment,{children:[D.jsx("input",{ref:t,type:"file",accept:j21.join(","),style:{display:"none"},onChange:i,"aria-label":a("upload:uploadImageButton"),"data-testid":"upload-file-input"}),D.jsx(Vi,{tooltipText:a("upload:uploadImageButton"),rounded:!0,size:"icon",onClick:o,disabled:n,"data-testid":"upload-attachment-button",children:n?D.jsx(z21,{size:18}):D.jsx(Xc,{size:20})})]})},cA2=({placeholder:a,isTyping:t,onSendMessage:n})=>{const{t:l}=Ee(),{isLoading:o,isUploadEnabled:i}=Gc(),[s,u]=e.useState(""),A=e.useRef(null),p=s.trim().length===0||t||o,g=C=>{u(C.target.value)},V=C=>{C==null||C.preventDefault(),!p&&(n(s),u(""))},v=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),V(C))},L=()=>W2("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",p?"text-gray-300":"text-primary");return D.jsx("footer",{className:"relative bottom-0 left-0 right-0 border-t border-gray-200 bg-white",children:D.jsxs("div",{className:"p-4",children:[D.jsx(Qd2,{}),D.jsx("form",{onSubmit:V,children:D.jsxs("div",{className:"flex w-full max-w-full items-center space-x-2",children:[i&&D.jsx(oA2,{}),D.jsxs("div",{className:"relative w-full flex-1",ref:A,children:[D.jsxs("div",{className:"invisible max-h-[164px] min-h-[44px] overflow-y-hidden whitespace-pre-wrap break-words px-4 py-2",children:[s||a,"|"]}),D.jsx("label",{htmlFor:"chat-input-textarea",className:"sr-only",children:a}),D.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:s,onKeyDown:v,onChange:g,rows:1}),t?D.jsx("div",{"data-testid":"stop-button",className:L(),children:D.jsx(jh,{weight:"bold",className:"h-6 w-6"})}):D.jsx("button",{"data-testid":"send-button",className:L(),"aria-label":l("common:send"),disabled:p,children:D.jsx(Kc,{weight:"fill",className:"h-6 w-6"})})]})]})})]})})},H9={drawerContent:"_drawerContent_ndll7_1",container:"_container_ndll7_9",title:"_title_ndll7_18",buttonContainer:"_buttonContainer_ndll7_27",button:"_button_ndll7_27"},iA2=()=>{const{t:a}=Ee("resumeChat"),{closeModal:t}=Rd(),{handleRestart:n,state:l}=Ve(),o=()=>{t(),s("continue")},i=()=>{n(),t(),s("start_new")},s=u=>{var A;Xu("conversation_resume",{action:u,conversation_id:l.conversationId??"",last_message_at:(A=l.messages.at(-1))==null?void 0:A.sent_at})};return D.jsx(Ei,{className:H9.drawerContent,children:D.jsxs("div",{className:H9.container,children:[D.jsxs(Q7,{className:H9.title,children:[a("title"),D.jsx("br",{})," ",a("subtitle")]}),D.jsxs("div",{className:H9.buttonContainer,children:[D.jsx(H4,{onClick:o,variant:"secondary",className:H9.button,"data-testid":"continue-button",children:a("continueButton")}),D.jsx(H4,{onClick:i,variant:"secondary",className:H9.button,"data-testid":"start-new-button",children:a("startNewButton")})]})]})})},sA2=()=>{const{state:a}=Ve(),{openModal:t}=Rd();e.useEffect(()=>{!a.hasResumedConversation&&mA2(a.messages)&&(a.hasResumedConversation=!0,setTimeout(()=>{t(Pr.Drawer,D.jsx(iA2,{}))},1e3))},[a.messages,a.hasResumedConversation,t])},mA2=a=>a.some(t=>t.blocks.some(n=>n.type==="ended"||n.type==="closed")),uA2=()=>{var l,o;const{t:a}=Ee(["common","footer"]),{sendNewMessage:t,state:n}=Ve();return sA2(),D.jsxs(D.Fragment,{children:[((l=n.settings)==null?void 0:l.theme)!=="slim"&&D.jsx(i52,{}),D.jsx(O52,{position:"top-center",expand:!0,pauseWhenPageIsHidden:!0,richColors:!0}),D.jsx("main",{className:"flex-1 space-y-2 overflow-hidden bg-white",children:D.jsx($7,{initial:!0,children:D.jsx(rl.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:D.jsx(Xd2,{})})})}),D.jsx(cA2,{placeholder:a(((o=n.settings)==null?void 0:o.newMessagePlaceholder)??a("footer:newMessagePlaceholder")),isTyping:n.isTyping,onSendMessage:t})]})},hA2=a=>{const[t,n]=e.useState(null);return e.useEffect(()=>{if(!a)return;(async()=>{try{const i=await new Yg0(a,new $H(_Z0())).fetchWidgetSettings();n(i)}catch(o){Ye(o)}})()},[a]),{widgetSettings:t}},dA2=(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}},AA2=a=>({handleOpen:()=>{Xu("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:l=>{setTimeout(()=>{globalThis.postMessage({event:x8.START,payload:{suggestionMessage:l}},globalThis.location.origin),globalThis.dispatchEvent(new Event(x8.OPEN))},400)}}),pA2="https://cdn.jsdelivr.net/npm/@freeday-ai/webchat",fA2=()=>{e.useEffect(()=>{const a=n=>{W21(n.error)},t=n=>{W21(n.reason)};return globalThis.addEventListener("error",a),globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("error",a),globalThis.removeEventListener("unhandledrejection",t)}},[])},W21=a=>{var t;(t=a==null?void 0:a.stack)!=null&&t.includes(pA2)&&Ye(a)};class ZA2 extends e.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){Ye(t,"Uncaught rendering error",{componentStack:n.componentStack})}render(){return this.props.children}}function HA2(a){e.useEffect(()=>{if(!a)return;const t=document.body,n=window.scrollY,l=t.style.position,o=t.style.top;return t.style.position="fixed",t.style.top=`-${n}px`,t.style.width="100%",()=>{t.style.position=l,t.style.top=o,window.scrollTo(0,n)}},[a])}const hA={chatWindowRenderer:"_chatWindowRenderer_1ihak_1",fullScreen:"_fullScreen_1ihak_22",widgetChatContainer:"_widgetChatContainer_1ihak_37",buttonContainer:"_buttonContainer_1ihak_43"},gA2=({channelId:a,metadata:t})=>{fA2();const{widgetSettings:n}=hA2(a);return!a||!n?null:D.jsx(ZA2,{children:D.jsx(s51,{config:{...n,metadata:t?JSON.parse(t):void 0},inShadowDom:!0,children:D.jsx(EA2,{widgetSettings:{...n,metadata:t?JSON.parse(t):void 0}})})})},EA2=({widgetSettings:a})=>{const t=a.startView===C3.FULL_SCREEN,n=a.startView===C3.UNFOLDED_CHAT_VIEW,l=t||n,{isWidgetOpen:o,setIsWidgetOpen:i}=dA2(l),{handleOpen:s,handleOpenAndSendMessage:u}=AA2(a),A=fd("(max-width: 640px)");return HA2(o&&A),e.useEffect(()=>{if(!l)return;i(!0);const p=requestAnimationFrame(s);return()=>cancelAnimationFrame(p)},[]),D.jsxs(D.Fragment,{children:[D.jsx($7,{children:o&&D.jsx(rl.div,{className:W2(hA.chatWindowRenderer,{[hA.fullScreen]: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?(p,g)=>`translateX(-50%) ${g}`:void 0,children:D.jsx(pr2,{children:D.jsx("div",{className:hA.widgetChatContainer,children:D.jsx(uA2,{})})})})}),!t&&D.jsx($7,{children:!o&&D.jsx(rl.div,{className:hA.buttonContainer,"data-testid":"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:D.jsx(tn2,{onOpen:s,onSendMessage:u})})})]})};J41("freeday-widget",gA2,["channelId","metadata"]);const G21=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:G21},rZ.bootstrap=G21,Object.defineProperty(rZ,Symbol.toStringTag,{value:"Module"}),rZ})({});
331
+ `))}function A(L,C,I,x){const N=I.enter("tableCell"),O=I.enter("phrasing"),B=I.containerPhrasing(L,{...x,before:i,after:i});return O(),N(),B}function p(L,C){return qu2(L,{align:C,alignDelimiters:l,padding:n,stringLength:o})}function g(L,C,I){const x=L.children;let N=-1;const O=[],B=C.enter("table");for(;++N<x.length;)O[N]=V(x[N],C,I);return B(),O}function V(L,C,I){const x=L.children;let N=-1;const O=[],B=C.enter("tableRow");for(;++N<x.length;)O[N]=A(x[N],L,C,I);return B(),O}function v(L,C,I){let x=L21.inlineCode(L,C,I);return I.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function xh2(){return{exit:{taskListCheckValueChecked:y21,taskListCheckValueUnchecked:y21,paragraph:Nh2}}}function Th2(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$h2}}}function y21(a){const t=this.stack[this.stack.length-2];t.type,t.checked=a.type==="taskListCheckValueChecked"}function Nh2(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 $h2(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=L21.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 kh2(){return[pu2(),$u2(),Ou2(),yh2(),xh2()]}function Dh2(a){return{extensions:[fu2(),ku2(a),_u2(),Rh2(a),Th2()]}}const Ph2={tokenize:jh2,partial:!0},F21={tokenize:qh2,partial:!0},C21={tokenize:Wh2,partial:!0},b21={tokenize:Gh2,partial:!0},Oh2={tokenize:Yh2,partial:!0},I21={name:"wwwAutolink",tokenize:Uh2,previous:R21},S21={name:"protocolAutolink",tokenize:zh2,previous:x21},j3={name:"emailAutolink",tokenize:Bh2,previous:T21},Ut={};function _h2(){return{text:Ut}}let Wr=48;for(;Wr<123;)Ut[Wr]=j3,Wr++,Wr===58?Wr=65:Wr===91&&(Wr=97);Ut[43]=j3,Ut[45]=j3,Ut[46]=j3,Ut[95]=j3,Ut[72]=[j3,S21],Ut[104]=[j3,S21],Ut[87]=[j3,I21],Ut[119]=[j3,I21];function Bh2(a,t,n){const l=this;let o,i;return s;function s(V){return!ld0(V)||!T21.call(l,l.previous)||rd0(l.events)?n(V):(a.enter("literalAutolink"),a.enter("literalAutolinkEmail"),u(V))}function u(V){return ld0(V)?(a.consume(V),u):V===64?(a.consume(V),A):n(V)}function A(V){return V===46?a.check(Oh2,g,p)(V):V===45||V===95||I6(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&&J6(l.previous)?(a.exit("literalAutolinkEmail"),a.exit("literalAutolink"),t(V)):n(V)}}function Uh2(a,t,n){const l=this;return o;function o(s){return s!==87&&s!==119||!R21.call(l,l.previous)||rd0(l.events)?n(s):(a.enter("literalAutolink"),a.enter("literalAutolinkWww"),a.check(Ph2,a.attempt(F21,a.attempt(C21,i),n),n)(s))}function i(s){return a.exit("literalAutolinkWww"),a.exit("literalAutolink"),t(s)}}function zh2(a,t,n){const l=this;let o="",i=!1;return s;function s(V){return(V===72||V===104)&&x21.call(l,l.previous)&&!rd0(l.events)?(a.enter("literalAutolink"),a.enter("literalAutolinkHttp"),o+=String.fromCodePoint(V),a.consume(V),u):n(V)}function u(V){if(J6(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||Bd(V)||M8(V)||Br(V)||Ud(V)?n(V):a.attempt(F21,a.attempt(C21,g),n)(V)}function g(V){return a.exit("literalAutolinkHttp"),a.exit("literalAutolink"),t(V)}}function jh2(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 qh2(a,t,n){let l,o,i;return s;function s(p){return p===46||p===95?a.check(b21,A,u)(p):p===null||M8(p)||Br(p)||p!==45&&Ud(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 Wh2(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(b21,t,i)(s):s===null||M8(s)||Br(s)?t(s):(a.consume(s),o)}function i(s){return s===41&&l++,a.consume(s),o}}function Gh2(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)||Br(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||M8(u)||Br(u)?t(u):l(u)}function i(u){return J6(u)?s(u):n(u)}function s(u){return u===59?(a.consume(u),l):J6(u)?(a.consume(u),s):n(u)}}function Yh2(a,t,n){return l;function l(i){return a.consume(i),o}function o(i){return I6(i)?n(i):t(i)}}function R21(a){return a===null||a===40||a===42||a===95||a===91||a===93||a===126||M8(a)}function x21(a){return!J6(a)}function T21(a){return!(a===47||ld0(a))}function ld0(a){return a===43||a===45||a===46||a===95||I6(a)}function rd0(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 Kh2={tokenize:ld2,partial:!0};function Xh2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ad2,continuation:{tokenize:td2},exit:nd2}},text:{91:{name:"gfmFootnoteCall",tokenize:ed2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Qh2,resolveTo:Jh2}}}}function Qh2(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=Ka(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 Jh2(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 ed2(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(Ka(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 ad2(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=Ka(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),G2(a,L,"gfmFootnoteDefinitionWhitespace")):n(C)}function L(C){return t(C)}}function td2(a,t,n){return a.check(Ri,t,a.attempt(Kh2,t,n))}function nd2(a){a.exit("gfmFootnoteDefinition")}function ld2(a,t,n){const l=this;return G2(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 rd2(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&&Y4(v,v.length,0,zd(L,s.slice(p+1,A),u)),Y4(v,v.length,0,[["exit",V,u],["enter",s[A][1],u],["exit",s[A][1],u],["exit",g,u]]),Y4(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=o9(p);if(C===126)return V>1?A(C):(s.consume(C),V++,L);if(V<2&&!n)return A(C);const x=s.exit("strikethroughSequenceTemporary"),N=o9(C);return x._open=!N||N===2&&!!I,x._close=!I||I===2&&!!N,u(C)}}}class od2{constructor(){this.map=[]}add(t,n,l){cd2(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 cd2(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 id2(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 sd2(){return{flow:{null:{name:"table",tokenize:md2,resolveAll:ud2}}}}function md2(a,t,n){const l=this;let o=0,i=0,s;return u;function u(Q){let Z0=l.events.length-1;for(;Z0>-1;){const a0=l.events[Z0][1].type;if(a0==="lineEnding"||a0==="linePrefix")Z0--;else break}const c0=Z0>-1?l.events[Z0][1].type:null,l0=c0==="tableHead"||c0==="tableRow"?q:A;return l0===q&&l.parser.lazy[l.now().line]?n(Q):l0(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):X1(Q)?i>1?(i=0,l.interrupt=!0,a.exit("tableRow"),a.enter("lineEnding"),a.consume(Q),a.exit("lineEnding"),L):n(Q):P2(Q)?G2(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,P2(Q)?G2(a,C,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Q):C(Q))}function C(Q){return Q===45||Q===58?x(Q):Q===124?(s=!0,a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),I):Y(Q)}function I(Q){return P2(Q)?G2(a,x,"whitespace")(Q):x(Q)}function x(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||X1(Q)?j(Q):Y(Q)}function N(Q){return Q===45?(a.enter("tableDelimiterFiller"),O(Q)):Y(Q)}function O(Q){return Q===45?(a.consume(Q),O):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 P2(Q)?G2(a,j,"whitespace")(Q):j(Q)}function j(Q){return Q===124?C(Q):Q===null||X1(Q)?!s||o!==i?Y(Q):(a.exit("tableDelimiterRow"),a.exit("tableHead"),t(Q)):Y(Q)}function Y(Q){return n(Q)}function q(Q){return a.enter("tableRow"),G(Q)}function G(Q){return Q===124?(a.enter("tableCellDivider"),a.consume(Q),a.exit("tableCellDivider"),G):Q===null||X1(Q)?(a.exit("tableRow"),t(Q)):P2(Q)?G2(a,G,"whitespace")(Q):(a.enter("data"),J(Q))}function J(Q){return Q===null||Q===124||M8(Q)?(a.exit("data"),G(Q)):(a.consume(Q),Q===92?f0:J)}function f0(Q){return Q===92||Q===124?(a.consume(Q),J):J(Q)}}function ud2(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 od2;for(;++n<a.length;){const L=a[n],C=L[1];L[0]==="enter"?C.type==="tableHead"?(u=!1,A!==0&&(N21(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=uA(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=uA(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=uA(v,t,i,o,n,V)):s[1]!==0&&(V=uA(v,t,s,o,n,V)),o=0):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(s[3]=n)}for(A!==0&&N21(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=id2(t.events,n))}return a}function uA(a,t,n,l,o,i){const s=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(i.end=Object.assign({},f9(t.events,n[0])),a.add(n[0],0,[["exit",i,t]]));const A=f9(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=f9(t.events,n[2]),g=f9(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({},f9(t.events,o)),a.add(o,0,[["exit",i,t]]),i=void 0),i}function N21(a,t,n,l,o){const i=[],s=f9(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 f9(a,t){const n=a[t],l=n[0]==="enter"?"start":"end";return n[1][l]}const hd2={name:"tasklistCheck",tokenize:Ad2};function dd2(){return{text:{91:hd2}}}function Ad2(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 X1(A)?t(A):P2(A)?a.check({tokenize:pd2},t,n)(A):n(A)}}function pd2(a,t,n){return G2(a,l,"whitespace");function l(o){return o===null?n(o):t(o)}}function fd2(a){return e01([_h2(),Xh2(),rd2(a),sd2(),dd2()])}const Zd2={};function Hd2(a){const t=this,n=a||Zd2,l=t.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),i=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),s=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(fd2(n)),i.push(kh2()),s.push(Dh2(n))}const gd2=Bu0("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"}}),od0=e.forwardRef(({settings:a,className:t,variant:n,isLastInGroup:l,isFirstInGroup:o,sentAt:i,layout:s,children:u,testId:A="",userName:p,...g},V)=>D.jsxs("div",{"data-testid":n=="received"?`chat-message-${A} incoming-message-${A}`:`chat-message-${A} outgoing-message-${A}`,children:[n&&o&&Vd2({variant:n,settings:a,userName:p}),D.jsx("div",{className:W2(gd2({variant:n,layout:s,isLastInGroup:l,className:t}),a!=null&&a.avatar?"pl-6":""),ref:V,...g,children:u})]}));od0.displayName="Message";const Ed2=Bu0("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"}}),Z9=e.forwardRef(({className:a,variant:t,layout:n,isLoading:l=!1,children:o,...i},s)=>D.jsx("div",{className:W2(Ed2({variant:t,layout:n,isLoading:l,className:a}),"overflow-x-auto break-words"),ref:s,...i,children:o}));Z9.displayName="MessageBubble";const Vd2=({variant:a,settings:t,userName:n})=>a!=="received"?null:D.jsxs("div",{className:"mb-1 flex items-center justify-start space-x-1",children:[(t==null?void 0:t.avatar)&&D.jsx("img",{width:48,height:48,className:"mt-1 h-5 w-5 rounded-full",src:t.avatar,alt:"Avatar"}),n&&D.jsx("span",{className:"font-brand text-[11.2px] font-bold leading-[16.8px] text-primary",children:n})]}),Md2=({block:a,variant:t,layout:n,isLoading:l})=>D.jsx(Z9,{variant:t,layout:n,isLoading:l,className:"prose max-w-[95%] break-words prose-a:text-blue-600",children:D.jsx(z01,{rehypePlugins:[r21],remarkPlugins:[Hd2],components:{a:vd2},className:"",skipHtml:!0,children:a.content})});function vd2(a){return D.jsx("a",{href:a.href,target:"_blank",children:a.children})}const $21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("rounded-lg border bg-card text-card-foreground shadow-sm",a),...t}));$21.displayName="Card";const k21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("flex flex-col space-y-1.5 p-6",a),...t}));k21.displayName="CardHeader";const D21=e.forwardRef(({className:a,...t},n)=>D.jsx("h3",{ref:n,className:W2("text-2xl font-semibold leading-none tracking-tight",a),...t}));D21.displayName="CardTitle";const P21=e.forwardRef(({className:a,...t},n)=>D.jsx("p",{ref:n,className:W2("text-sm text-muted-foreground",a),...t}));P21.displayName="CardDescription";const O21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("p-6 pt-0",a),...t}));O21.displayName="CardContent";const _21=e.forwardRef(({className:a,...t},n)=>D.jsx("div",{ref:n,className:W2("flex items-center p-6 pt-0",a),...t}));_21.displayName="CardFooter";const Ld2=({block:a})=>{const{t}=Ee("common");return a.sources.some(l=>l.document_metadata&&l.document_metadata.card)?D.jsx("div",{className:"flex w-full max-w-full gap-5 overflow-x-auto",children:a.sources.map(l=>D.jsxs($21,{"data-url":l.source_link,className:"min-w-[200px] max-w-72 overflow-hidden",children:[D.jsx(k21,{className:"h-full max-h-[120px] p-0",children:D.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})}),D.jsxs(O21,{className:"p-4",children:[D.jsx(D21,{className:"text-md line-clamp-1 font-bold",children:l.document_metadata.card.title}),l.document_metadata.card.description&&D.jsx(P21,{className:"line-clamp-2 text-sm",children:l.document_metadata.card.description})]}),D.jsx(_21,{children:D.jsx("a",{href:l.document_metadata.card.url,target:"_blank",children:D.jsx(H4,{variant:"outline",children:l.document_metadata.card.call_to_action_text??t("sourceCallToActionLabel")})})})]},l.id))}):D.jsx(D.Fragment,{})},wd2=({block:a,variant:t,layout:n,isLoading:l})=>D.jsx(Z9,{variant:t,layout:n,isLoading:l,className:"max-w-[95%]",children:D.jsx("img",{src:a.url,alt:a.filename})}),B21={markdown:Md2,text:({block:a,variant:t,layout:n,isLoading:l})=>D.jsx(Z9,{variant:t,layout:n,isLoading:l,className:"prose max-w-[60%]",children:D.jsx("p",{children:a.text})}),button:V0.Fragment,button_group:_52,source_group:Ld2,image_reference:wd2},yd2=a=>a in B21,U21=(a,t,n)=>{const l=B21[a.type];return l!==void 0?V0.createElement(l,{key:`block-${a.id}`,variant:t,layout:n,block:a}):(console.warn(`No component found for block type: ${a.type}`),null)},Fd2=150,Cd2=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>Fd2)},[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}},bd2=()=>{var o;const{t:a}=Ee(),{state:t}=Ve(),n=e.useMemo(()=>{const i=u=>u.type==="text"||u.type==="markdown",s=t.messages.filter(u=>!E7(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 D.jsx("div",{className:"sr-only","aria-live":"polite",children:t.isTyping?l:n.map(i=>U21(i,"sent","default"))})},Id2=({messages:a})=>{const{state:t}=Ve(),{userId:n,isTyping:l,hasSentMessageThisSession:o}=t,{hasUploadState:i}=Gc(),s=e.useMemo(()=>{const A=[...Sd2(a)],p=a.at(-1);return(p?E7(p,n):!1)&&l&&A.push({id:"typing-indicator",type:"typing-indicator"}),i&&A.push({id:"upload-bubble",type:"upload-bubble"}),xd2(A,n,o||i)},[a,n,l,o,i]),u=e.useMemo(()=>s.length,[s.length]);return{chatGroups:s,groupCount:u}},Sd2=a=>a.map((t,n)=>{const l=a[n+1],o=a[n-1];return{id:`message-${t.id}-${n}`,type:"message",message:t,index:n,isFirstInGroup:o?t.sender_id!==o.sender_id:!0,isLastInGroup:l?t.sender_id!==l.sender_id:!0}}),Rd2=(a,t)=>a.type==="message"&&E7(a.message,t)||a.type==="upload-bubble",xd2=(a,t,n)=>{const l=[];let o=[];for(const i of a)Rd2(i,t)&&o.length>0?(l.push({id:`group-${l.length}`,items:o,showPlaceholder:!1}),o=[i]):o.push(i);return o.length>0&&l.push({id:`group-${l.length}`,items:o,showPlaceholder:n}),l};function Td2({message:a,handleActionEvent:t,close:n}){return D.jsxs(Cd,{className:"sm:max-w-[425px]",children:[D.jsxs(Su0,{children:[D.jsx(Ru0,{children:"Thank you for your response!"}),D.jsx(yQ0,{children:"Can you tell us what went wrong?"})]}),D.jsx(kd2,{message:a,handleActionEvent:t,close:n})]})}function Nd2({message:a,handleActionEvent:t,close:n}){const{t:l}=Ee(["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 D.jsxs(Ei,{className:"min-h-40 overflow-hidden rounded-t-[20px] border-primary bg-primary text-primary-foreground",children:[D.jsx($7,{children:D.jsx(rl.div,{layoutId:"underline",children:D.jsx(Sd,{className:"",children:A?D.jsx(AJ0,{title:l("feedback:modalSubmittedTitle"),description:l("feedback:modalSubmittedDescription")}):D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsx("div",{className:"relative w-12"}),D.jsxs("div",{className:"text-center",children:[D.jsx(Q7,{className:"text-center",children:l("feedback:modalTitle")}),D.jsx(_u0,{className:"text-primary-foreground/80",children:l("feedback:modalDescription")})]}),D.jsx(Ou0,{className:"w-12",asChild:!0,children:D.jsx(H4,{variant:"link",onClick:n,className:"text-right text-primary-foreground",children:D.jsx(Jn,{weight:"regular",size:20})})})]})})})}),A?D.jsx(D.Fragment,{}):D.jsxs(rl.form,{onSubmit:g,className:"mt-auto flex flex-col gap-2 p-4 pt-2",children:[D.jsx($d,{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)}),D.jsx(H4,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",children:l(s?"sending":"send")})]})]})}const $d2=({message:a,handleActionEvent:t})=>{const{t:n}=Ee("common"),{openModal:l,closeModal:o}=Rd(),i=fd("(min-width: 768px)"),{state:s}=Ve(),u=A=>{A.preventDefault(),t("feedback-pressed",{id:a.id,value:"negative"}),i&&!s.inShadowDom?l(Pr.Dialog,D.jsx(Td2,{message:a,handleActionEvent:t,close:o})):l(Pr.Drawer,D.jsx(Nd2,{message:a,handleActionEvent:t,close:o}))};return D.jsxs("div",{className:"flex justify-start space-x-3",children:[D.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:[D.jsx($G0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="positive"?"fill":"regular",size:20})," ",D.jsx("span",{children:n("feedback:thumbsUp")})]}),D.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:[D.jsx(NG0,{"aria-hidden":!0,focusable:"false",weight:a.user_feedback_value==="negative"?"fill":"regular",size:20})," ",D.jsx("span",{children:n("feedback:thumbsDown")})]})]})},kd2=({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 D.jsxs("form",{"data-testid":"feedback-form",onSubmit:A,className:W2("mt-auto flex flex-col gap-2",l),children:[D.jsx($d,{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)}),D.jsx(H4,{disabled:s||!o,type:"submit",variant:"secondary","data-testid":"feedback-form-button",children:"Send"})]})},Dd2=({message:a,index:t,isLastInGroup:n,isFirstInGroup:l,...o})=>{var L;const{state:i,handleActionEvent:s}=Ve(),{messages:u,userId:A}=i,p=t===u.length-1,g=A?E7(a,A):!1,V=g?"sent":"received",v=g?"default":"ai";return D.jsx("div",{...o,children:D.jsxs(od0,{settings:i.settings,testId:t.toString(),variant:V,isFirstInGroup:l,isLastInGroup:n,sentAt:p?a.sent_at:null,userName:a.sender_name?a.sender_name:(L=i.settings)==null?void 0:L.digitalEmployeeName,className:"",children:[a.blocks.map(C=>U21(C,V,v)),a.request_user_feedback&&!g&&D.jsx($d2,{message:a,handleActionEvent:s})]})})},Pd2=()=>D.jsxs("div",{className:"flex items-center gap-1",children:[D.jsx("div",{className:"bubble1 h-2 w-2 rounded-full"}),D.jsx("div",{className:"bubble2 h-2 w-2 rounded-full"}),D.jsx("div",{className:"bubble3 h-2 w-2 rounded-full"})]}),Od2=()=>{var t;const{state:a}=Ve();return D.jsx(od0,{settings:a.settings,userName:(t=a.settings)==null?void 0:t.digitalEmployeeName,testId:"loading",variant:"received",isFirstInGroup:!0,isLastInGroup:!1,sentAt:null,className:"",children:D.jsx(Z9,{variant:"received",layout:"ai",className:"prose max-w-[60%]",children:D.jsx(Pd2,{})})},"message-loading")},_d2={spinner:"_spinner_mxybw_1"},z21=({size:a=20,className:t=""})=>D.jsx("div",{className:`${_d2.spinner} ${t}`,style:{width:a,height:a},"aria-hidden":"true"}),w4={container:"_container_1e6ea_1",bubble:"_bubble_1e6ea_7",error:"_error_1e6ea_11",uploadingPlaceholder:"_uploadingPlaceholder_1e6ea_15",spinner:"_spinner_1e6ea_22",uploadingText:"_uploadingText_1e6ea_26",content:"_content_1e6ea_30",fileContainer:"_fileContainer_1e6ea_36",fileInfo:"_fileInfo_1e6ea_42",fileIcon:"_fileIcon_1e6ea_48",fileName:"_fileName_1e6ea_52",errorContainer:"_errorContainer_1e6ea_59",errorIcon:"_errorIcon_1e6ea_65",errorText:"_errorText_1e6ea_69"},Bd2=()=>{const{file:a,error:t}=Gc();return D.jsx("div",{className:w4.container,children:D.jsx(Z9,{variant:"sent",layout:"default",className:xZ(w4.bubble,{[w4.error]:!!t}),children:D.jsx("div",{className:w4.content,children:D.jsx(Ud2,{file:a,error:t})})})})},Ud2=({file:a,error:t})=>{const{t:n}=Ee(),l=e.useMemo(()=>a&&URL.createObjectURL(a),[a]);if(t)return D.jsxs("div",{className:w4.errorContainer,children:[D.jsx(Gh,{size:20,className:w4.errorIcon}),D.jsx("span",{className:w4.errorText,children:t})]});if(!a||!l)return D.jsxs("div",{className:w4.uploadingPlaceholder,children:[D.jsx(z21,{size:18,className:w4.spinner}),D.jsx("span",{className:w4.uploadingText,children:n("upload:uploadingText")})]});const o=()=>{URL.revokeObjectURL(l)};return D.jsxs("div",{className:w4.fileContainer,children:[D.jsx("img",{src:l,alt:a.name,onLoad:o}),D.jsxs("div",{className:w4.fileInfo,children:[D.jsx(Xc,{size:16,className:w4.fileIcon}),D.jsx("span",{className:w4.fileName,children:a==null?void 0:a.name})]})]})},zd2=({item:a})=>{switch(a.type){case"message":return D.jsx(Dd2,{message:a.message,index:a.index,isLastInGroup:a.isLastInGroup,isFirstInGroup:a.isFirstInGroup});case"typing-indicator":return D.jsx(Od2,{});case"upload-bubble":return D.jsx(Bd2,{});default:return null}},jd2=({group:a,placeholderMinHeight:t})=>D.jsx("div",{className:"flex flex-col gap-3",style:{minHeight:a.showPlaceholder?t:void 0},children:a.items.map(n=>D.jsx(zd2,{item:n},n.id))},a.id),qd2=({disclaimer:a})=>D.jsx("div",{children:D.jsx(z01,{rehypePlugins:[r21],className:"!m-0 max-w-none text-center text-[10px] leading-[14px] text-gray-500",skipHtml:!0,components:{a:Wd2},children:a})}),Wd2=({href:a="",children:t,...n})=>D.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",...n,children:t});function Gd2(a){return a?a.map(t=>({...t,blocks:t.blocks?t.blocks.filter(n=>yd2(n.type)):[]})):[]}function Yd2(a){return a?a.filter(t=>t.blocks&&t.blocks.length>0):[]}const Kd2=16;function Xd2(){var C,I,x,N;const a=e.useRef(null),{state:t,endDivRef:n,scrollableDivRef:l}=Ve(),{scrollToBottom:o,isScrolledUp:i}=Cd2(l.current),[s,u]=e.useState(!1),A=e.useMemo(()=>{const O=Gd2(t.messages);return Yd2(O)},[t.messages]),{chatGroups:p,groupCount:g}=Id2({messages:A});e.useEffect(()=>{p.some(B=>B.showPlaceholder)&&l.current&&setTimeout(()=>{var B;(B=l.current)==null||B.scrollTo({top:l.current.scrollHeight,behavior:"smooth"})},100)},[g,l]),e.useEffect(()=>{!s&&t.messages.length>0&&(u(!0),setTimeout(()=>{var O,B;(B=l.current)==null||B.scrollTo({top:(O=l.current)==null?void 0:O.scrollHeight})},0))},[t.messages,s]);const V=((C=l.current)==null?void 0:C.clientHeight)||0,v=Kd2+(((I=a.current)==null?void 0:I.clientHeight)||0),L=`${V-v}px`;return D.jsxs("div",{className:"relative h-full w-full",children:[D.jsx(bd2,{}),D.jsxs("div",{className:"flex h-full w-full flex-col overflow-y-auto",ref:l,children:[D.jsxs("div",{className:"flex grow flex-col gap-3 px-4 py-2",children:[((x=t.settings)==null?void 0:x.disclaimer)&&D.jsx(qd2,{disclaimer:t.settings.disclaimer}),p.map(O=>D.jsx(jd2,{group:O,placeholderMinHeight:L},O.id))]}),((N=t.settings)==null?void 0:N.showFreedayBranding)&&D.jsx(Uu0,{ref:a,name:"Freeday",site:"https://freeday.ai",className:"shrink-0 pb-4 pt-8"})]}),D.jsx("div",{ref:n}),i&&D.jsx(H4,{variant:"outline",size:"icon",onClick:o,className:"absolute bottom-2 left-1/2 -translate-x-1/2 border border-border p-1",children:D.jsx(vh,{size:18})})]})}const Qd2=()=>{var u,A,p,g;const{state:a}=Ve(),{t}=Ee(),[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?D.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:D.jsxs("div",{className:"flex h-full w-full flex-col justify-center rounded-t-[30px] bg-primary/10 p-6",children:[D.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:D.jsx(Jn,{weight:"regular",size:20,className:"text-primary"})}),D.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)&&D.jsx("p",{className:"whitespace-pre-line text-sm",children:(g=a.settings)==null?void 0:g.bannerMessage})]})}):null},j21=["image/jpeg","image/jpg","image/png","image/gif","image/webp"],Jd2=async(a,t=100)=>{const n=t*1024;if(a.size<=n)return a;let l=.9,o=a;for(;o.size>n&&l>.1;)o=await lA2(a,l),l-=.1;return o},eA2=(a,t,n=2048)=>a<=n&&t<=n?{width:a,height:t}:a>t?{width:n,height:t/a*n}:{width:a/t*n,height:n},aA2=a=>new Promise((t,n)=>{const l=new Image;l.onload=()=>t(l),l.onerror=()=>n(new Error("Failed to load image")),l.src=a}),tA2=a=>new Promise((t,n)=>{const l=new FileReader;l.onload=o=>{var i;return t((i=o.target)==null?void 0:i.result)},l.onerror=()=>n(new Error("Failed to read file")),l.readAsDataURL(a)}),nA2=(a,t,n,l)=>new Promise((o,i)=>{a.toBlob(s=>{if(!s){i(new Error("Failed to compress image"));return}const u=new File([s],t,{type:n,lastModified:Date.now()});o(u)},n,l)}),lA2=async(a,t)=>{const n=await tA2(a),l=await aA2(n),o=document.createElement("canvas"),i=eA2(l.width,l.height);o.width=i.width,o.height=i.height;const s=o.getContext("2d");if(!s)throw new Error("Failed to get canvas context");return s.drawImage(l,0,0,i.width,i.height),nA2(o,a.name,a.type,t)},q21=50,rA2=()=>{const{t:a}=Ee(),{setFile:t,setError:n,setIsLoading:l,clearUploadedFile:o}=Gc(),i=async A=>{n(null);const p=u(A);if(p){s(p),o();return}try{l(!0);const g=await Jd2(A,100);await new Promise(V=>setTimeout(V,2e3)),t(g)}catch(g){console.error("Error processing image:",g),s(a("upload:processingError"))}finally{l(!1)}},s=A=>{n(A),o()},u=A=>{if(!j21.includes(A.type))return a("upload:invalidFileType");const p=q21*1024*1024;if(A.size>p)return a("upload:fileSizeExceeded",{maxSize:q21})};return{uploadFile:i}},oA2=()=>{const{t:a}=Ee(),{fileInputRef:t,isLoading:n}=Gc(),{uploadFile:l}=rA2(),o=()=>{var s;(s=t.current)==null||s.click()},i=s=>{var A;const u=(A=s.target.files)==null?void 0:A[0];u&&l(u)};return D.jsxs(D.Fragment,{children:[D.jsx("input",{ref:t,type:"file",accept:j21.join(","),style:{display:"none"},onChange:i,"aria-label":a("upload:uploadImageButton"),"data-testid":"upload-file-input"}),D.jsx(Vi,{tooltipText:a("upload:uploadImageButton"),rounded:!0,size:"icon",onClick:o,disabled:n,"data-testid":"upload-attachment-button",children:n?D.jsx(z21,{size:18}):D.jsx(Xc,{size:20})})]})},cA2=({placeholder:a,isTyping:t,onSendMessage:n})=>{const{t:l}=Ee(),{isLoading:o,isUploadEnabled:i}=Gc(),[s,u]=e.useState(""),A=e.useRef(null),p=s.trim().length===0||t||o,g=C=>{u(C.target.value)},V=C=>{C==null||C.preventDefault(),!p&&(n(s),u(""))},v=C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),V(C))},L=()=>W2("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",p?"text-gray-300":"text-primary");return D.jsx("footer",{className:"relative bottom-0 left-0 right-0 border-t border-gray-200 bg-white",children:D.jsxs("div",{className:"p-4",children:[D.jsx(Qd2,{}),D.jsx("form",{onSubmit:V,children:D.jsxs("div",{className:"flex w-full max-w-full items-center space-x-2",children:[i&&D.jsx(oA2,{}),D.jsxs("div",{className:"relative w-full flex-1",ref:A,children:[D.jsxs("div",{className:"invisible max-h-[164px] min-h-[44px] overflow-y-hidden whitespace-pre-wrap break-words px-4 py-2",children:[s||a,"|"]}),D.jsx("label",{htmlFor:"chat-input-textarea",className:"sr-only",children:a}),D.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:s,onKeyDown:v,onChange:g,rows:1}),t?D.jsx("div",{"data-testid":"stop-button",className:L(),children:D.jsx(jh,{weight:"bold",className:"h-6 w-6"})}):D.jsx("button",{"data-testid":"send-button",className:L(),"aria-label":l("common:send"),disabled:p,children:D.jsx(Kc,{weight:"fill",className:"h-6 w-6"})})]})]})})]})})},H9={drawerContent:"_drawerContent_ndll7_1",container:"_container_ndll7_9",title:"_title_ndll7_18",buttonContainer:"_buttonContainer_ndll7_27",button:"_button_ndll7_27"},iA2=()=>{const{t:a}=Ee("resumeChat"),{closeModal:t}=Rd(),{handleRestart:n,state:l}=Ve(),o=()=>{t(),s("continue")},i=()=>{n(),t(),s("start_new")},s=u=>{var A;Xu("conversation_resume",{action:u,conversation_id:l.conversationId??"",last_message_at:(A=l.messages.at(-1))==null?void 0:A.sent_at})};return D.jsx(Ei,{className:H9.drawerContent,children:D.jsxs("div",{className:H9.container,children:[D.jsxs(Q7,{className:H9.title,children:[a("title"),D.jsx("br",{})," ",a("subtitle")]}),D.jsxs("div",{className:H9.buttonContainer,children:[D.jsx(H4,{onClick:o,variant:"secondary",className:H9.button,"data-testid":"continue-button",children:a("continueButton")}),D.jsx(H4,{onClick:i,variant:"secondary",className:H9.button,"data-testid":"start-new-button",children:a("startNewButton")})]})]})})},sA2=()=>{const{state:a}=Ve(),{openModal:t}=Rd();e.useEffect(()=>{!a.hasResumedConversation&&mA2(a.messages)&&(a.hasResumedConversation=!0,setTimeout(()=>{t(Pr.Drawer,D.jsx(iA2,{}))},500))},[a.messages,a.hasResumedConversation,t])},mA2=a=>a.some(t=>t.blocks.some(n=>n.type==="ended")),uA2=()=>{var l,o;const{t:a}=Ee(["common","footer"]),{sendNewMessage:t,state:n}=Ve();return sA2(),D.jsxs(D.Fragment,{children:[((l=n.settings)==null?void 0:l.theme)!=="slim"&&D.jsx(i52,{}),D.jsx(O52,{position:"top-center",expand:!0,pauseWhenPageIsHidden:!0,richColors:!0}),D.jsx("main",{className:"flex-1 space-y-2 overflow-hidden bg-white",children:D.jsx($7,{initial:!0,children:D.jsx(rl.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:D.jsx(Xd2,{})})})}),D.jsx(cA2,{placeholder:a(((o=n.settings)==null?void 0:o.newMessagePlaceholder)??a("footer:newMessagePlaceholder")),isTyping:n.isTyping,onSendMessage:t})]})},hA2=a=>{const[t,n]=e.useState(null);return e.useEffect(()=>{if(!a)return;(async()=>{try{const i=await new Yg0(a,new $H(_Z0())).fetchWidgetSettings();n(i)}catch(o){Ye(o)}})()},[a]),{widgetSettings:t}},dA2=(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}},AA2=a=>({handleOpen:()=>{Xu("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:l=>{setTimeout(()=>{globalThis.postMessage({event:x8.START,payload:{suggestionMessage:l}},globalThis.location.origin),globalThis.dispatchEvent(new Event(x8.OPEN))},400)}}),pA2="https://cdn.jsdelivr.net/npm/@freeday-ai/webchat",fA2=()=>{e.useEffect(()=>{const a=n=>{W21(n.error)},t=n=>{W21(n.reason)};return globalThis.addEventListener("error",a),globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("error",a),globalThis.removeEventListener("unhandledrejection",t)}},[])},W21=a=>{var t;(t=a==null?void 0:a.stack)!=null&&t.includes(pA2)&&Ye(a)};class ZA2 extends e.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){Ye(t,"Uncaught rendering error",{componentStack:n.componentStack})}render(){return this.props.children}}function HA2(a){e.useEffect(()=>{if(!a)return;const t=document.body,n=window.scrollY,l=t.style.position,o=t.style.top;return t.style.position="fixed",t.style.top=`-${n}px`,t.style.width="100%",()=>{t.style.position=l,t.style.top=o,window.scrollTo(0,n)}},[a])}const hA={chatWindowRenderer:"_chatWindowRenderer_1ihak_1",fullScreen:"_fullScreen_1ihak_22",widgetChatContainer:"_widgetChatContainer_1ihak_37",buttonContainer:"_buttonContainer_1ihak_43"},gA2=({channelId:a,metadata:t})=>{fA2();const{widgetSettings:n}=hA2(a);return!a||!n?null:D.jsx(ZA2,{children:D.jsx(s51,{config:{...n,metadata:t?JSON.parse(t):void 0},inShadowDom:!0,children:D.jsx(EA2,{widgetSettings:{...n,metadata:t?JSON.parse(t):void 0}})})})},EA2=({widgetSettings:a})=>{const t=a.startView===C3.FULL_SCREEN,n=a.startView===C3.UNFOLDED_CHAT_VIEW,l=t||n,{isWidgetOpen:o,setIsWidgetOpen:i}=dA2(l),{handleOpen:s,handleOpenAndSendMessage:u}=AA2(a),A=fd("(max-width: 640px)");return HA2(o&&A),e.useEffect(()=>{if(!l)return;i(!0);const p=requestAnimationFrame(s);return()=>cancelAnimationFrame(p)},[]),D.jsxs(D.Fragment,{children:[D.jsx($7,{children:o&&D.jsx(rl.div,{className:W2(hA.chatWindowRenderer,{[hA.fullScreen]: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?(p,g)=>`translateX(-50%) ${g}`:void 0,children:D.jsx(pr2,{children:D.jsx("div",{className:hA.widgetChatContainer,children:D.jsx(uA2,{})})})})}),!t&&D.jsx($7,{children:!o&&D.jsx(rl.div,{className:hA.buttonContainer,"data-testid":"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:D.jsx(tn2,{onOpen:s,onSendMessage:u})})})]})};J41("freeday-widget",gA2,["channelId","metadata"]);const G21=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:G21},rZ.bootstrap=G21,Object.defineProperty(rZ,Symbol.toStringTag,{value:"Module"}),rZ})({});
package/dist/webchat.mjs CHANGED
@@ -117610,12 +117610,10 @@ const EE2 = () => {
117610
117610
  e.useEffect(() => {
117611
117611
  !a.hasResumedConversation && kE2(a.messages) && (a.hasResumedConversation = !0, setTimeout(() => {
117612
117612
  t(K5.Drawer, /* @__PURE__ */ D.jsx(NE2, {}));
117613
- }, 1e3));
117613
+ }, 500));
117614
117614
  }, [a.messages, a.hasResumedConversation, t]);
117615
117615
  }, kE2 = (a) => a.some(
117616
- (t) => t.blocks.some(
117617
- (n) => n.type === "ended" || n.type === "closed"
117618
- )
117616
+ (t) => t.blocks.some((n) => n.type === "ended")
117619
117617
  ), DE2 = () => {
117620
117618
  var l, o;
117621
117619
  const { t: a } = Se(["common", "footer"]), { sendNewMessage: t, state: n } = Re();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freeday-ai/webchat",
3
- "version": "2025.11.14.07.49.9030",
3
+ "version": "2025.11.14.08.30.6191",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"