@opencx/widget 3.0.74 → 3.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/designs.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),uu=require("@radix-ui/react-popover"),X=require("react"),W=require("./useWidgetTrigger-Cm-L4gPy.cjs"),lu=require("@radix-ui/react-dialog"),le=require("lucide-react"),va=require("clsx"),fr=require("react-dom"),cu=require("@radix-ui/react-slot"),be=require("framer-motion"),du=require("@radix-ui/react-avatar"),hu=require("@radix-ui/react-tooltip"),hi=require("tinycolor2"),fu=require("react-dropzone"),pu=require("@radix-ui/react-dropdown-menu"),Gn=require("zod");function It(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Dn=It(uu),ye=It(X),ze=It(lu),St=It(du),sn=It(hu),me=It(pu);function fi(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const Ne=st(/[A-Za-z]/),Ae=st(/[\dA-Za-z]/),mu=st(/[#-'*+\--9=?A-Z^-~]/);function Cn(e){return e!==null&&(e<32||e===127)}const pr=st(/\d/),gu=st(/[\dA-Fa-f]/),bu=st(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function J(e){return e===-2||e===-1||e===32}const vn=st(new RegExp("\\p{P}|\\p{S}","u")),pt=st(/\s/);function st(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Eu(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Pn=function(e){if(e==null)return yu;if(typeof e=="function")return Mn(e);if(typeof e=="object")return Array.isArray(e)?Tu(e):xu(e);if(typeof e=="string")return wu(e);throw new Error("Expected function, string, or object as test")};function Tu(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Pn(e[n]);return Mn(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function xu(e){const t=e;return Mn(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function wu(e){return Mn(t);function t(n){return n&&n.type===e}}function Mn(e){return t;function t(n,r,i){return!!(_u(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function yu(){return!0}function _u(e){return e!==null&&typeof e=="object"&&"type"in e}const Pa=[],Au=!0,mr=!1,Cu="skip";function Ma(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=Pn(i),s=r?-1:1;u(e,void 0,[])();function u(l,c,d){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const p=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return g;function g(){let p=Pa,E,y,k;if((!t||a(l,c,d[d.length-1]||void 0))&&(p=ku(n(l,d)),p[0]===mr))return p;if("children"in l&&l.children){const _=l;if(_.children&&p[0]!==Cu)for(y=(r?_.children.length:-1)+s,k=d.concat(_);y>-1&&y<_.children.length;){const S=_.children[y];if(E=u(S,y,k)(),E[0]===mr)return E;y=typeof E[1]=="number"?E[1]:y+s}}return p}}}function ku(e){return Array.isArray(e)?e:typeof e=="number"?[Au,e]:e==null?Pa:[e]}function Nu(e,t,n){const i=Pn((n||{}).ignore||[]),a=Iu(t);let s=-1;for(;++s<a.length;)Ma(e,"text",u);function u(c,d){let h=-1,g;for(;++h<d.length;){const p=d[h],E=g?g.children:void 0;if(i(p,E?E.indexOf(p):void 0,g))return;g=p}if(g)return l(c,d)}function l(c,d){const h=d[d.length-1],g=a[s][0],p=a[s][1];let E=0;const k=h.children.indexOf(c);let _=!1,S=[];g.lastIndex=0;let L=g.exec(c.value);for(;L;){const M=L.index,F={index:L.index,input:L.input,stack:[...d,c]};let I=p(...L,F);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=M+1:(E!==M&&S.push({type:"text",value:c.value.slice(E,M)}),Array.isArray(I)?S.push(...I):I&&S.push(I),E=M+L[0].length,_=!0),!g.global)break;L=g.exec(c.value)}return _?(E<c.value.length&&S.push({type:"text",value:c.value.slice(E)}),h.children.splice(k,1,...S)):S=[c],k+S.length}}function Iu(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Su(i[0]),Ou(i[1])])}return t}function Su(e){return typeof e=="string"?new RegExp(Eu(e),"g"):e}function Ou(e){return typeof e=="function"?e:function(){return e}}const Qn="phrasing",Xn=["autolink","link","image","label"];function Lu(){return{transforms:[Fu],enter:{literalAutolink:Du,literalAutolinkEmail:Kn,literalAutolinkHttp:Kn,literalAutolinkWww:Kn},exit:{literalAutolink:Bu,literalAutolinkEmail:Mu,literalAutolinkHttp:vu,literalAutolinkWww:Pu}}}function Ru(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:":",before:"[ps]",after:"\\/",inConstruct:Qn,notInConstruct:Xn}]}}function Du(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Kn(e){this.config.enter.autolinkProtocol.call(this,e)}function vu(e){this.config.exit.autolinkProtocol.call(this,e)}function Pu(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Mu(e){this.config.exit.autolinkEmail.call(this,e)}function Bu(e){this.exit(e)}function Fu(e){Nu(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Hu],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Uu]],{ignore:["link","linkReference"]})}function Hu(e,t,n,r,i){let a="";if(!Ba(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!zu(n)))return!1;const s=ju(n+r);if(!s[0])return!1;const u={type:"link",title:null,url:a+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[u,{type:"text",value:s[1]}]:u}function Uu(e,t,n,r){return!Ba(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zu(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ju(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=fi(e,"(");let a=fi(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function Ba(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||pt(n)||vn(n))&&(!t||n!==47)}function Ue(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}Fa.peek=Zu;function Yu(){return{enter:{gfmFootnoteDefinition:qu,gfmFootnoteDefinitionLabelString:Vu,gfmFootnoteCall:Xu,gfmFootnoteCallString:Ku},exit:{gfmFootnoteDefinition:Qu,gfmFootnoteDefinitionLabelString:Gu,gfmFootnoteCall:Ju,gfmFootnoteCallString:$u}}}function Wu(){return{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:el,footnoteReference:Fa}}}function qu(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Vu(){this.buffer()}function Gu(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Qu(e){this.exit(e)}function Xu(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ku(){this.buffer()}function $u(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Ju(e){this.exit(e)}function Fa(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteReference"),u=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),s(),a+=i.move("]"),a}function Zu(){return"["}function el(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteDefinition"),u=n.enter("label");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),a+=i.move("]:"+(e.children&&e.children.length>0?" ":"")),i.shift(4),a+=i.move(n.indentLines(n.containerFlow(e,i.current()),tl)),s(),a}function tl(e,t,n){return t===0?e:(n?"":" ")+e}const nl=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ha.peek=ol;function rl(){return{canContainEols:["delete"],enter:{strikethrough:al},exit:{strikethrough:sl}}}function il(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nl}],handlers:{delete:Ha}}}function al(e){this.enter({type:"delete",children:[]},e)}function sl(e){this.exit(e)}function Ha(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let s=i.move("~~");return s+=n.containerPhrasing(e,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),a(),s}function ol(){return"~"}function ul(e,t={}){const n=(t.align||[]).concat(),r=t.stringLength||cl,i=[],a=[],s=[],u=[];let l=0,c=-1;for(;++c<e.length;){const E=[],y=[];let k=-1;for(e[c].length>l&&(l=e[c].length);++k<e[c].length;){const _=ll(e[c][k]);if(t.alignDelimiters!==!1){const S=r(_);y[k]=S,(u[k]===void 0||S>u[k])&&(u[k]=S)}E.push(_)}a[c]=E,s[c]=y}let d=-1;if(typeof n=="object"&&"length"in n)for(;++d<l;)i[d]=pi(n[d]);else{const E=pi(n);for(;++d<l;)i[d]=E}d=-1;const h=[],g=[];for(;++d<l;){const E=i[d];let y="",k="";E===99?(y=":",k=":"):E===108?y=":":E===114&&(k=":");let _=t.alignDelimiters===!1?1:Math.max(1,u[d]-y.length-k.length);const S=y+"-".repeat(_)+k;t.alignDelimiters!==!1&&(_=y.length+_+k.length,_>u[d]&&(u[d]=_),g[d]=_),h[d]=S}a.splice(1,0,h),s.splice(1,0,g),c=-1;const p=[];for(;++c<a.length;){const E=a[c],y=s[c];d=-1;const k=[];for(;++d<l;){const _=E[d]||"";let S="",L="";if(t.alignDelimiters!==!1){const M=u[d]-(y[d]||0),F=i[d];F===114?S=" ".repeat(M):F===99?M%2?(S=" ".repeat(M/2+.5),L=" ".repeat(M/2-.5)):(S=" ".repeat(M/2),L=S):L=" ".repeat(M)}t.delimiterStart!==!1&&!d&&k.push("|"),t.padding!==!1&&!(t.alignDelimiters===!1&&_==="")&&(t.delimiterStart!==!1||d)&&k.push(" "),t.alignDelimiters!==!1&&k.push(S),k.push(_),t.alignDelimiters!==!1&&k.push(L),t.padding!==!1&&k.push(" "),(t.delimiterEnd!==!1||d!==l-1)&&k.push("|")}p.push(t.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return p.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),uu=require("@radix-ui/react-popover"),X=require("react"),W=require("./useWidgetTrigger-CiYy4rS2.cjs"),lu=require("@radix-ui/react-dialog"),le=require("lucide-react"),va=require("clsx"),fr=require("react-dom"),cu=require("@radix-ui/react-slot"),be=require("framer-motion"),du=require("@radix-ui/react-avatar"),hu=require("@radix-ui/react-tooltip"),hi=require("tinycolor2"),fu=require("react-dropzone"),pu=require("@radix-ui/react-dropdown-menu"),Gn=require("zod");function It(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Dn=It(uu),ye=It(X),ze=It(lu),St=It(du),sn=It(hu),me=It(pu);function fi(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const Ne=st(/[A-Za-z]/),Ae=st(/[\dA-Za-z]/),mu=st(/[#-'*+\--9=?A-Z^-~]/);function Cn(e){return e!==null&&(e<32||e===127)}const pr=st(/\d/),gu=st(/[\dA-Fa-f]/),bu=st(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function J(e){return e===-2||e===-1||e===32}const vn=st(new RegExp("\\p{P}|\\p{S}","u")),pt=st(/\s/);function st(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Eu(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Pn=function(e){if(e==null)return yu;if(typeof e=="function")return Mn(e);if(typeof e=="object")return Array.isArray(e)?Tu(e):xu(e);if(typeof e=="string")return wu(e);throw new Error("Expected function, string, or object as test")};function Tu(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Pn(e[n]);return Mn(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function xu(e){const t=e;return Mn(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function wu(e){return Mn(t);function t(n){return n&&n.type===e}}function Mn(e){return t;function t(n,r,i){return!!(_u(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function yu(){return!0}function _u(e){return e!==null&&typeof e=="object"&&"type"in e}const Pa=[],Au=!0,mr=!1,Cu="skip";function Ma(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=Pn(i),s=r?-1:1;u(e,void 0,[])();function u(l,c,d){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const p=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return g;function g(){let p=Pa,E,y,k;if((!t||a(l,c,d[d.length-1]||void 0))&&(p=ku(n(l,d)),p[0]===mr))return p;if("children"in l&&l.children){const _=l;if(_.children&&p[0]!==Cu)for(y=(r?_.children.length:-1)+s,k=d.concat(_);y>-1&&y<_.children.length;){const S=_.children[y];if(E=u(S,y,k)(),E[0]===mr)return E;y=typeof E[1]=="number"?E[1]:y+s}}return p}}}function ku(e){return Array.isArray(e)?e:typeof e=="number"?[Au,e]:e==null?Pa:[e]}function Nu(e,t,n){const i=Pn((n||{}).ignore||[]),a=Iu(t);let s=-1;for(;++s<a.length;)Ma(e,"text",u);function u(c,d){let h=-1,g;for(;++h<d.length;){const p=d[h],E=g?g.children:void 0;if(i(p,E?E.indexOf(p):void 0,g))return;g=p}if(g)return l(c,d)}function l(c,d){const h=d[d.length-1],g=a[s][0],p=a[s][1];let E=0;const k=h.children.indexOf(c);let _=!1,S=[];g.lastIndex=0;let L=g.exec(c.value);for(;L;){const M=L.index,F={index:L.index,input:L.input,stack:[...d,c]};let I=p(...L,F);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?g.lastIndex=M+1:(E!==M&&S.push({type:"text",value:c.value.slice(E,M)}),Array.isArray(I)?S.push(...I):I&&S.push(I),E=M+L[0].length,_=!0),!g.global)break;L=g.exec(c.value)}return _?(E<c.value.length&&S.push({type:"text",value:c.value.slice(E)}),h.children.splice(k,1,...S)):S=[c],k+S.length}}function Iu(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([Su(i[0]),Ou(i[1])])}return t}function Su(e){return typeof e=="string"?new RegExp(Eu(e),"g"):e}function Ou(e){return typeof e=="function"?e:function(){return e}}const Qn="phrasing",Xn=["autolink","link","image","label"];function Lu(){return{transforms:[Fu],enter:{literalAutolink:Du,literalAutolinkEmail:Kn,literalAutolinkHttp:Kn,literalAutolinkWww:Kn},exit:{literalAutolink:Bu,literalAutolinkEmail:Mu,literalAutolinkHttp:vu,literalAutolinkWww:Pu}}}function Ru(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Qn,notInConstruct:Xn},{character:":",before:"[ps]",after:"\\/",inConstruct:Qn,notInConstruct:Xn}]}}function Du(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Kn(e){this.config.enter.autolinkProtocol.call(this,e)}function vu(e){this.config.exit.autolinkProtocol.call(this,e)}function Pu(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Mu(e){this.config.exit.autolinkEmail.call(this,e)}function Bu(e){this.exit(e)}function Fu(e){Nu(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Hu],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Uu]],{ignore:["link","linkReference"]})}function Hu(e,t,n,r,i){let a="";if(!Ba(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!zu(n)))return!1;const s=ju(n+r);if(!s[0])return!1;const u={type:"link",title:null,url:a+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[u,{type:"text",value:s[1]}]:u}function Uu(e,t,n,r){return!Ba(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function zu(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ju(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=fi(e,"(");let a=fi(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function Ba(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||pt(n)||vn(n))&&(!t||n!==47)}function Ue(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}Fa.peek=Zu;function Yu(){return{enter:{gfmFootnoteDefinition:qu,gfmFootnoteDefinitionLabelString:Vu,gfmFootnoteCall:Xu,gfmFootnoteCallString:Ku},exit:{gfmFootnoteDefinition:Qu,gfmFootnoteDefinitionLabelString:Gu,gfmFootnoteCall:Ju,gfmFootnoteCallString:$u}}}function Wu(){return{unsafe:[{character:"[",inConstruct:["phrasing","label","reference"]}],handlers:{footnoteDefinition:el,footnoteReference:Fa}}}function qu(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Vu(){this.buffer()}function Gu(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Qu(e){this.exit(e)}function Xu(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Ku(){this.buffer()}function $u(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.label=t,n.identifier=Ue(this.sliceSerialize(e)).toLowerCase()}function Ju(e){this.exit(e)}function Fa(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteReference"),u=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),s(),a+=i.move("]"),a}function Zu(){return"["}function el(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const s=n.enter("footnoteDefinition"),u=n.enter("label");return a+=i.move(n.safe(n.associationId(e),{...i.current(),before:a,after:"]"})),u(),a+=i.move("]:"+(e.children&&e.children.length>0?" ":"")),i.shift(4),a+=i.move(n.indentLines(n.containerFlow(e,i.current()),tl)),s(),a}function tl(e,t,n){return t===0?e:(n?"":" ")+e}const nl=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ha.peek=ol;function rl(){return{canContainEols:["delete"],enter:{strikethrough:al},exit:{strikethrough:sl}}}function il(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nl}],handlers:{delete:Ha}}}function al(e){this.enter({type:"delete",children:[]},e)}function sl(e){this.exit(e)}function Ha(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let s=i.move("~~");return s+=n.containerPhrasing(e,{...i.current(),before:s,after:"~"}),s+=i.move("~~"),a(),s}function ol(){return"~"}function ul(e,t={}){const n=(t.align||[]).concat(),r=t.stringLength||cl,i=[],a=[],s=[],u=[];let l=0,c=-1;for(;++c<e.length;){const E=[],y=[];let k=-1;for(e[c].length>l&&(l=e[c].length);++k<e[c].length;){const _=ll(e[c][k]);if(t.alignDelimiters!==!1){const S=r(_);y[k]=S,(u[k]===void 0||S>u[k])&&(u[k]=S)}E.push(_)}a[c]=E,s[c]=y}let d=-1;if(typeof n=="object"&&"length"in n)for(;++d<l;)i[d]=pi(n[d]);else{const E=pi(n);for(;++d<l;)i[d]=E}d=-1;const h=[],g=[];for(;++d<l;){const E=i[d];let y="",k="";E===99?(y=":",k=":"):E===108?y=":":E===114&&(k=":");let _=t.alignDelimiters===!1?1:Math.max(1,u[d]-y.length-k.length);const S=y+"-".repeat(_)+k;t.alignDelimiters!==!1&&(_=y.length+_+k.length,_>u[d]&&(u[d]=_),g[d]=_),h[d]=S}a.splice(1,0,h),s.splice(1,0,g),c=-1;const p=[];for(;++c<a.length;){const E=a[c],y=s[c];d=-1;const k=[];for(;++d<l;){const _=E[d]||"";let S="",L="";if(t.alignDelimiters!==!1){const M=u[d]-(y[d]||0),F=i[d];F===114?S=" ".repeat(M):F===99?M%2?(S=" ".repeat(M/2+.5),L=" ".repeat(M/2-.5)):(S=" ".repeat(M/2),L=S):L=" ".repeat(M)}t.delimiterStart!==!1&&!d&&k.push("|"),t.padding!==!1&&!(t.alignDelimiters===!1&&_==="")&&(t.delimiterStart!==!1||d)&&k.push(" "),t.alignDelimiters!==!1&&k.push(S),k.push(_),t.alignDelimiters!==!1&&k.push(L),t.padding!==!1&&k.push(" "),(t.delimiterEnd!==!1||d!==l-1)&&k.push("|")}p.push(t.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return p.join(`
2
2
  `)}function ll(e){return e==null?"":String(e)}function cl(e){return e.length}function pi(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}const mi={}.hasOwnProperty;function Ua(e,t){const n=t||{};function r(i,...a){let s=r.invalid;const u=r.handlers;if(i&&mi.call(i,e)){const l=String(i[e]);s=mi.call(u,l)?u[l]:r.unknown}if(s)return s.call(this,i,...a)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}function dl(e,t,n,r){const i=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const s=n.indentLines(n.containerFlow(e,a.current()),hl);return i(),s}function hl(e,t,n){return">"+(n?"":" ")+e}function fl(e,t){return gi(e,t.inConstruct,!0)&&!gi(e,t.notInConstruct,!1)}function gi(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function bi(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
3
3
  `&&fl(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
4
4
  `}function pl(e,t){const n=String(e);let r=n.indexOf(t),i=r,a=0,s=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++a>s&&(s=a):a=1,i=r+t.length,r=n.indexOf(t,i);return s}function ml(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function gl(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function bl(e,t,n,r){const i=gl(n),a=e.value||"",s=i==="`"?"GraveAccent":"Tilde";if(ml(e,n)){const h=n.enter("codeIndented"),g=n.indentLines(a,El);return h(),g}const u=n.createTracker(r),l=i.repeat(Math.max(pl(a,i)+1,3)),c=n.enter("codeFenced");let d=u.move(l);if(e.lang){const h=n.enter(`codeFencedLang${s}`);d+=u.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...u.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${s}`);d+=u.move(" "),d+=u.move(n.safe(e.meta,{before:d,after:`
@@ -42,7 +42,7 @@
42
42
  ${i.screens.welcome.width},
43
43
  ${i.screens.sessions.width},
44
44
  ${i.screens.chat.width}
45
- )`)};return{theme:i,computed:a,cssVars:eb({palette:i.palette,primary:i.primaryColor})}}function eb({palette:e,primary:t}){const n=tb(e),r=hi(t).toHsl(),i=hi(t).isLight()?n[950]:n[50];return{"--opencx-primary":`${r.h} ${r.s*100}% ${r.l*100}%`,"--opencx-primary-foreground":i,"--opencx-background":n[100],"--opencx-foreground":n[950],"--opencx-destructive":"0 72.2% 50.6%","--opencx-destructive-foreground":n[50],"--opencx-accent":n[200],"--opencx-accent-foreground":"var(--opencx-foreground)","--opencx-secondary":n[200],"--opencx-secondary-foreground":"var(--opencx-foreground)","--opencx-muted":n[200],"--opencx-muted-foreground":n[500],"--opencx-input":n[300],"--opencx-border":n[300],"--opencx-ring":"var(--opencx-foreground)"}}function tb(e){const t={50:"0 0% 98%",100:"0 0% 96.1%",200:"0 0% 89.8%",300:"0 0% 83.1%",400:"0 0% 63.9%",500:"0 0% 45.1%",600:"0 0% 32.2%",700:"0 0% 25.1%",800:"0 0% 14.9%",900:"0 0% 9%",950:"0 0% 3.9%"},n={50:"60 9.1% 97.8%",100:"60 4.8% 95.9%",200:"20 5.9% 90%",300:"24 5.7% 82.9%",400:"24 5.4% 63.9%",500:"25 5.3% 44.7%",600:"33.3 5.5% 32.4%",700:"30 6.3% 25.1%",800:"12 6.5% 15.1%",900:"24 9.8% 10%",950:"20 14.3% 4.1%"},r={50:"0 0% 98%",100:"240 4.8% 95.9%",200:"240 5.9% 90%",300:"240 4.9% 83.9%",400:"240 5% 64.9%",500:"240 3.8% 46.1%",600:"240 5.2% 33.9%",700:"240 5.3% 26.1%",800:"240 3.7% 15.9%",900:"240 5.9% 10%",950:"240 10% 3.9%"},i={50:"210 40% 98%",100:"210 40% 96.1%",200:"214.3 31.8% 91.4%",300:"212.7 26.8% 83.9%",400:"215 20.2% 65.1%",500:"215.4 16.3% 46.9%",600:"215.3 19.3% 34.5%",700:"215.3 25% 26.7%",800:"217.2 32.6% 17.5%",900:"222.2 47.4% 11.2%",950:"222.2 84% 4.9%"};switch(e){case"neutral":return t;case"stone":return n;case"zinc":return r;case"slate":return i;default:return t}}const ii=()=>{const[e,t]=X.useState("ltr");return X.useEffect(()=>{const n=()=>{typeof document>"u"||t(window.getComputedStyle(document.body).direction)};n();const r=new MutationObserver(n);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),r.observe(document.body,{attributes:!0,attributeFilter:["dir"]}),window.addEventListener("languagechange",n),()=>{r.disconnect(),window.removeEventListener("languagechange",n)}},[]),e},nb={ok:"حسنا",yes:"نعم",no:"لا",agree:"موافق",cancel:"إلغاء","yes-exit":"نعم، اخرج","yes-reset":"نعم، إعادة تعيين","no-cancel":"لا، إلغاء","are-you-sure":"هل أنت متأكد؟",recording:"تسجيل","thank-you":"شكرا","sorry-try-again":"عذرا، حاول مرة أخرى","error-occurred":"حدث خطأ","please-try-again":"يرجى المحاولة مرة أخرى","write-a-message":"اكتب رسالة...","send-message":"إرسال رسالة",connected:"متصل",connecting:"جاري الاتصال",reconnecting:"جاري إعادة الاتصال",reconnected:"تم إعادة الاتصال",disconnecting:"جاري قطع الاتصال",disconnected:"قطع الاتصال",error:"خطأ","persist-session":"حفظ الجلسة",settings:"إعدادات",close:"إغلاق",help:"مساعدة",chat:"محادثة",send:"إرسال",copy:"نسخ",copied:"تم النسخ","sound-effects":"التاثيرات الصوتية",language:"اللغة",select:"اختر",agent:"الوكيل",user:"المستخدم",bot:"البوت","close-widget":"إغلاق الودجة","got-any-questions":"هل لديك أي أسئلة؟ تحدث معنا!","typical-response-time":"عادة ما نرد في أقل من دقيقة واحدة","session-closed-lead":"تم حل مشكلتك!",exit:"خروج","create-new-ticket":"إنشاء تذكرة جديدة","reset-conversation":"إعادة تعيين المحادثة","new-conversation":"محادثة جديدة","welcome-title":"مرحبًا بك في دردشة الدعم الخاصة بنا","welcome-description":"نحن هنا للمساعدة! ابدأ محادثة وسنرد عليك في أقرب وقت ممكن.","your-name":"اسمك","your-email":"عنوان بريدك الإلكتروني","start-chat":"تحدث إلى الدعم","starting-chat":"جاري الاتصال...","hello-greeting":"مرحبًا! كيف يمكننا مساعدتك اليوم؟","i-need-more-help":"أحتاج المزيد من المساعدة","this-was-helpful":"كان هذا مفيدًا",optional:"اختياري","no-conversations-yet":"لا يوجد محادثات"},rb={ok:"OK",yes:"Ja",no:"Nein",agree:"Zustimmen",cancel:"Stornieren","yes-exit":"Ja, beenden","yes-reset":"Ja, zurücksetzen","no-cancel":"Nein, abbrechen","are-you-sure":"Sind Sie sicher?",recording:"Aufnahme läuft","thank-you":"Vielen Dank","sorry-try-again":"Entschuldigung, bitte versuchen Sie es erneut","error-occurred":"Ein Fehler ist aufgetreten","please-try-again":"Bitte versuchen Sie es erneut","write-a-message":"Nachricht schreiben...","send-message":"Nachricht senden",connected:"Verbunden",connecting:"Verbindung wird hergestellt",reconnecting:"Verbindung wird wiederhergestellt",reconnected:"Wieder verbunden",disconnecting:"Verbindung wird getrennt",disconnected:"Verbindung getrennt",error:"Fehler","persist-session":"Sitzung beibehalten",settings:"Einstellungen",close:"Schließen",help:"Hilfe",chat:"Chat",send:"Senden",copy:"Kopieren",copied:"Kopiert","sound-effects":"Soundeffekte",language:"Sprache",select:"Auswählen",agent:"Agent",user:"Benutzer",bot:"Bot","got-any-questions":"Haben Sie Fragen? Chatten Sie mit uns!","typical-response-time":"Üblicherweise antworten wir in weniger als 1 Minute","close-widget":"Widget schließen","session-closed-lead":"Ihr Problem wurde gelöst!","create-new-ticket":"Neues Ticket erstellen",exit:"Beenden","reset-conversation":"Konversation zurücksetzen","new-conversation":"Neue Konversation","welcome-title":"Willkommen in unserem Support-Chat","welcome-description":"Wir sind hier, um zu helfen! Beginnen Sie ein Gesprách und wir werden so schnell wie mogelijk antworten.","your-name":"Ihr Name","your-email":"Ihre E-Mail-Adresse","start-chat":"Mit dem Support sprechen","starting-chat":"Verbindung wird hergestellt...","hello-greeting":"Hallo! Wie können wir Ihnen heute helfen?","i-need-more-help":"Ich brauche weitere Hilfe","this-was-helpful":"Dies war hilfreich",optional:"Optional","no-conversations-yet":"noch keine Gespräche"},ib={ok:"OK",yes:"Yes",no:"No",agree:"Agree",cancel:"Cancel","yes-exit":"Yes, exit","yes-reset":"Yes, reset","no-cancel":"No, cancel","are-you-sure":"Are you sure?",recording:"Recording...","thank-you":"Thank you","sorry-try-again":"Sorry, please try again","error-occurred":"An error occurred","please-try-again":"Please try again","write-a-message":"Write a message...","send-message":"Send message",connected:"Connected",connecting:"Connecting",reconnecting:"Reconnecting",reconnected:"Reconnected",disconnecting:"Disconnecting",disconnected:"Disconnected",error:"Error","persist-session":"Persist session",settings:"Settings",close:"Close",help:"Help",chat:"Chat",send:"Send",copy:"Copy",copied:"Copied","sound-effects":"Sound effects",language:"Language",select:"Select",agent:"Agent",user:"User",bot:"Bot","close-widget":"Close widget","got-any-questions":"Got any questions? Chat with us!","typical-response-time":"Typically respond in less than 1 minute","session-closed-lead":"Your issue has been resolved!","create-new-ticket":"Create new ticket",exit:"Exit","reset-conversation":"Reset conversation","new-conversation":"New conversation","welcome-title":"Welcome to our support chat","welcome-description":"We're here to help! Start a conversation and we'll get back to you as soon as possible.","your-name":"Your name","your-email":"Your email address","start-chat":"Talk to support","starting-chat":"Connecting...","hello-greeting":"Hi there!","i-need-more-help":"I need more help","this-was-helpful":"This was helpful",optional:"Optional","no-conversations-yet":"No conversations yet"},ab={ok:"D'accord",yes:"Oui",no:"Non",agree:"Accepter",cancel:"Annuler","yes-exit":"Oui, quitter","yes-reset":"Oui, réinitialiser","no-cancel":"Non, annuler","are-you-sure":"Êtes-vous sûr ?",recording:"Enregistrement...","thank-you":"Merci","sorry-try-again":"Désolé, veuillez réessayer","error-occurred":"Une erreur s'est produite","please-try-again":"Veuillez réessayer","write-a-message":"Écrivez un message...","send-message":"Envoyer le message",connected:"Connecté",connecting:"Connexion en cours",reconnecting:"Reconnexion en cours",reconnected:"Reconnecté",disconnecting:"Déconnexion en cours",disconnected:"Déconnecté",error:"Erreur","persist-session":"Conserver la session",settings:"Paramètres",close:"Fermer",help:"Aide",chat:"Chat",send:"Envoyer",copy:"Copier",copied:"Copié","sound-effects":"Effets sonores",language:"Langue",select:"Sélectionner",agent:"Agent",user:"Utilisateur",bot:"Bot","close-widget":"Fermer le widget","got-any-questions":"Vous avez des questions ? Chattez avec nous !","typical-response-time":"Nous répondons généralement en moins d'une minute","session-closed-lead":"Votre problème a été résolu !","create-new-ticket":"Créer un nouveau ticket",exit:"Sortie","reset-conversation":"Réinitialiser la conversation","new-conversation":"Nouvelle conversation","welcome-title":"Bienvenue dans notre chat de support","welcome-description":"Nous sommes là pour vous aider ! Commencez une conversation et nous vous répondrons dès que possible.","your-name":"Votre nom","your-email":"Votre adresse e-mail","start-chat":"Parler au support","starting-chat":"Connexion...","hello-greeting":"Bonjour ! Comment pouvons-nous vous aider aujourd'hui ?","i-need-more-help":"Je besoin d'aide plus","this-was-helpful":"C'était utile",optional:"Optionnel","no-conversations-yet":"Aucune conversation pour le moment"},sb={ok:"OK",yes:"Ja",no:"Nee",agree:"Akkoord",cancel:"Annuleren","yes-exit":"Ja, afsluiten","yes-reset":"Ja, resetten","no-cancel":"Nee, annuleren","are-you-sure":"Weet u het zeker?",recording:"Opname...","thank-you":"Dank u","sorry-try-again":"Sorry, probeer het opnieuw","error-occurred":"Er is een fout opgetreden","please-try-again":"Probeer het opnieuw","write-a-message":"Schrijf een bericht...","send-message":"Bericht verzenden",connected:"Verbonden",connecting:"Verbinding maken",reconnecting:"Opnieuw verbinding maken",reconnected:"Opnieuw verbonden",disconnecting:"Verbinding verbreken",disconnected:"Verbinding verbroken",error:"Fout","persist-session":"Sessie behouden",settings:"Instellingen",close:"Sluiten",help:"Help",chat:"Chat",send:"Verzenden",copy:"Kopiëren",copied:"Gekopieerd","sound-effects":"Geluidseffecten",language:"Taal",select:"Selecteren",agent:"Agent",user:"Gebruiker",bot:"Bot","close-widget":"Widget sluiten","got-any-questions":"Heeft u vragen? Chat met ons!","typical-response-time":"We reageren doorgaans binnen 1 minuut","session-closed-lead":"Uw probleem is opgelost!","create-new-ticket":"Nieuw ticket aanmaken",exit:"Afsluiten","reset-conversation":"Gesprek resetten","new-conversation":"Nieuw gesprek","welcome-title":"Welkom bij onze supportchat","welcome-description":"We zijn hier om te helpen! Begin een gesprek en we nemen zo snel mogelijk contact met u op.","your-name":"Uw naam","your-email":"Uw e-mailadres","start-chat":"Praat met ondersteuning","starting-chat":"Verbinding maken...","hello-greeting":"Hallo! Hoe kunnen we u vandaag helpen?","i-need-more-help":"Ik heb nog meer hulp nodig","this-was-helpful":"Mijn vraag is opgelost",optional:"Optioneel","no-conversations-yet":"Nog geen gesprekken"},ob={ok:"OK",yes:"Sim",no:"Não",agree:"Concordo",cancel:"Cancelar","yes-exit":"Sim, sair","yes-reset":"Sim, redefinir","no-cancel":"Não, cancelar","are-you-sure":"Você tem certeza?",recording:"Gravando...","thank-you":"Obrigado","sorry-try-again":"Desculpe, tente novamente","error-occurred":"Ocorreu um erro","please-try-again":"Por favor, tente novamente","write-a-message":"Escreva uma mensagem...","send-message":"Enviar mensagem",connected:"Conectado",connecting:"Conectando",reconnecting:"Reconectando",reconnected:"Reconectado",disconnecting:"Desconectando",disconnected:"Desconectado",error:"Erro","persist-session":"Persistir sessão",settings:"Configurações",close:"Fechar",help:"Ajuda",chat:"Bate-papo",send:"Enviar",copy:"Copiar",copied:"Copiado","sound-effects":"Efeitos sonoros",language:"Idioma",select:"Selecionar",agent:"Agente",user:"Usuário",bot:"Bot","close-widget":"Fechar widget","got-any-questions":"Tem alguma dúvida? Converse conosco!","typical-response-time":"Geralmente respondemos em menos de 1 minuto","session-closed-lead":"Seu problema foi resolvido!","create-new-ticket":"Criar novo ticket",exit:"Sair","reset-conversation":"Redefinir conversa","new-conversation":"Nova conversa","welcome-title":"Bem-vindo ao nosso chat de suporte","welcome-description":"Estamos aqui para ajudar! Inicie uma conversa e responderemos o mais rápido possível.","your-name":"Seu nome","your-email":"Seu endereço de email","start-chat":"Falar com o suporte","starting-chat":"Conectando...","hello-greeting":"Olá! Como podemos ajudar você hoje?","i-need-more-help":"preciso de mais ajuda","this-was-helpful":"Isso foi útil",optional:"Opcional","no-conversations-yet":"Nenhuma conversa ainda"},Vo={en:ib,ar:nb,nl:sb,fr:ab,de:rb,pt:ob},ub=Object.keys(Vo),lb=e=>ub.includes(e);function cb(e,t){const n=Vo[t];return n&&n[e]||""}function Bt(){const{widgetCtx:{config:e}}=W.useWidget();return X.useMemo(()=>{const n=lb(e.language)?e.language:"en";return{get:r=>cb(r,n),lang:n}},[e.language])}function ai({suggestion:e,className:t,...n}){const{sendMessage:r}=W.useMessages(),i=()=>{const a=e.trim();a&&r({content:a})};return f.jsx(Oe,{...re("chat/suggested_reply_btn"),size:"sm",className:q("rounded-xl w-fit",t),...n,onClick:i,children:e})}function db(){const e=Bt(),t=[e.get("i-need-more-help"),e.get("this-was-helpful")];return f.jsx("div",{...re("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:t.map(n=>f.jsx(ai,{suggestion:n,className:"flex-1"},n))})}function hb({file:{status:e,file:t,error:n},onCancel:r}){const[i,a]=X.useState(null);X.useEffect(()=>{if(!t.type.startsWith("image/"))return;const l=new FileReader;return l.onload=()=>a(l.result),l.onerror=()=>console.error("Error reading file"),l.readAsDataURL(t),()=>l.abort()},[t]);const s=()=>{switch(e){case"uploading":return f.jsx(le.Loader2,{className:"size-4 animate-spin"});case"error":return f.jsx(le.AlertCircle,{className:"size-4 text-destructive"});default:return null}},u=()=>{const l=t.type.split("/")[0];return l==="image"&&i?f.jsx("img",{src:typeof i=="string"?i:"",className:"object-cover bg-secondary size-full",alt:t.name}):l==="audio"?f.jsx(le.FileAudio2Icon,{}):l==="video"?f.jsx(le.FileVideo2Icon,{}):f.jsx(le.FileIcon,{})};return f.jsx(an,{side:"bottom",content:e==="error"?f.jsxs("span",{className:"text-destructive",children:["Failed to upload: ",n]}):t.name,children:f.jsxs("div",{className:q(e==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s()}),f.jsx("button",{type:"button",className:q("absolute bg-black/50 inset-0 size-full z-10 opacity-0","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:r,children:f.jsx(le.XIcon,{className:"size-4 text-primary-foreground"})}),f.jsx(u,{})]})})}function fb(){var j;const{isSmallScreen:e}=Mt(),t=X.useRef(null),{sendMessage:n}=W.useMessages(),{sessionState:r}=W.useSessions(),i=Bt(),a=ii(),[s,u]=X.useState(""),{allFiles:l,emptyTheFiles:c,handleCancelUpload:d,appendFiles:h,isUploading:g,successFiles:p}=W.useUploadFiles(),E=!!((j=r.session)!=null&&j.isHandedOff),{isAwaitingBotReply:y}=W.useIsAwaitingBotReply(),k=U=>{h(U)},_=!s.trim()&&p.length===0,S=async()=>{if(y||_)return;g&&console.info("please wait for the file(s) to upload");const U=s.trim();n({content:U,attachments:p.flatMap(z=>z.fileUrl?[{url:z.fileUrl,type:z.file.type,name:z.file.name,id:z.id,size:z.file.size}]:[])}),u(""),c()},{getRootProps:L,getInputProps:M,open:F}=fu.useDropzone({onDrop:k,noClick:!0,onDropRejected(){console.error("unsupported file type, or the file is too large")},maxSize:5*1024*1024,accept:E?{"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],"application/pdf":[".pdf"]}:{"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]}}),I=U=>{const z=U.clipboardData;z&&z.files.length>0&&k(Array.from(z.files))};return f.jsxs("div",{...re("chat/input_box/root"),className:"p-2 relative space-y-1",...L(),children:[f.jsx("input",{...M()}),f.jsxs("div",{...re("chat/input_box/inner_root"),className:q("transition-all","bg-white","relative rounded-3xl flex flex-col gap-2 p-2","hover:border-primary focus-within:border-primary"),children:[f.jsxs("div",{...re("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[l.length>0&&f.jsx("div",{...re("chat/input_box/attachments_container"),className:"flex items-center gap-1",children:f.jsx(be.AnimatePresence,{mode:"popLayout",children:l.map(U=>f.jsx(ae,{snapExit:!0,children:f.jsx(hb,{onCancel:()=>d(U.id),file:U})},U.id))})}),f.jsx("textarea",{...re("chat/input_box/textarea"),onPaste:I,ref:t,id:"chat-input",dir:a,value:s,rows:3,className:q("max-h-16 [field-sizing:content]","w-full resize-none px-2",l.length===0&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground","rtl:placeholder:text-right",e?"text-[16px]":"text-sm"),onChange:U=>u(U.target.value),onKeyDown:async U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),S())},placeholder:i.get("write-a-message")})]}),f.jsxs("div",{dir:a,className:"gap-2 flex justify-between rtl:text-right",children:[f.jsx(an,{side:"top",align:"start",content:"attach files, (maximum size 5mb)",children:f.jsx(Oe,{onClick:F,size:"fit",variant:"ghost",className:q("rounded-full size-8 flex items-center justify-center p-0 overflow-hidden"),children:f.jsx(be.AnimatePresence,{mode:"wait",children:E?f.jsx(ae,{children:f.jsx(le.PaperclipIcon,{className:"size-4"})},"paper-clip"):f.jsx(ae,{children:f.jsx(le.ImageIcon,{className:"size-4"})},"image-icon")})})}),f.jsx(an,{content:"send message",side:"top",align:"end",children:f.jsx(Oe,{size:"fit",onClick:S,disabled:y||g||_,className:"rounded-full size-8 flex items-center justify-center p-0",children:f.jsx(be.AnimatePresence,{mode:"wait",children:y||g?f.jsx(ae,{snapExit:!0,children:f.jsx(le.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):f.jsx(ae,{snapExit:!0,children:f.jsx(le.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})}function pb(){const{widgetCtx:e}=W.useWidget(),t=Bt();return f.jsx("div",{className:"p-2",children:f.jsxs("div",{className:"p-2 bg-muted rounded-3xl space-y-2",children:[f.jsxs("div",{className:"pl-2 flex items-center gap-1",children:[f.jsx(le.CircleCheckIcon,{className:"size-4 text-emerald-600"}),f.jsx("h2",{className:"text-sm font-medium",dir:"auto",children:t.get("session-closed-lead")})]}),f.jsx("div",{children:f.jsx(Oe,{onClick:e.resetChat,className:"rounded-2xl w-full",children:t.get("new-conversation")})})]})})}function mb(){var a;const{initialQuestions:e,initialQuestionsPosition:t}=W.useConfig(),{sessionState:n}=W.useSessions(),{messagesState:r}=W.useMessages(),i=r.messages.length===0;return f.jsx("footer",{children:f.jsx("div",{children:f.jsx(be.AnimatePresence,{mode:"wait",children:n.session&&!((a=n.session)!=null&&a.isOpened)?f.jsx(ae,{className:"overflow-hidden",overrides:{initial:{height:0},animate:{height:"auto"},exit:{height:0}},children:f.jsx(pb,{})},"session-closed"):f.jsxs(ae,{className:"overflow-hidden",overrides:{initial:{height:0},animate:{height:"auto"},exit:{height:0}},children:[r.lastAIResMightSolveUserIssue&&f.jsx(db,{}),i&&e&&t!=="below-initial-messages"&&f.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:e==null?void 0:e.map((s,u)=>f.jsx(ai,{suggestion:s},`${s}-${u}`))}),f.jsx(fb,{})]},"chat-input")})})})}const gb=me.Root,bb=me.Trigger,Eb=me.Group,Tb=ye.forwardRef(({className:e,inset:t,children:n,...r},i)=>f.jsxs(me.SubTrigger,{ref:i,className:q("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,f.jsx(le.ChevronRight,{className:"ml-auto"})]}));Tb.displayName=me.SubTrigger.displayName;const xb=ye.forwardRef(({className:e,...t},n)=>f.jsx(me.SubContent,{ref:n,className:q("z-50 min-w-[8rem] overflow-hidden rounded-2xl border bg-background p-1 text-foreground shadow-2xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));xb.displayName=me.SubContent.displayName;const Go=ye.forwardRef(({className:e,sideOffset:t=4,...n},r)=>f.jsx(me.Content,{ref:r,sideOffset:t,className:q("z-50 min-w-[8rem] overflow-hidden rounded-2xl border bg-background p-1 text-foreground shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Go.displayName=me.Content.displayName;const Qo=ye.forwardRef(({className:e,inset:t,...n},r)=>f.jsx(ae,{children:f.jsx(me.Item,{ref:r,className:q("relative flex cursor-default select-none items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n})}));Qo.displayName=me.Item.displayName;const wb=ye.forwardRef(({className:e,children:t,checked:n,...r},i)=>f.jsxs(me.CheckboxItem,{ref:i,className:q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(me.ItemIndicator,{children:f.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));wb.displayName=me.CheckboxItem.displayName;const yb=ye.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(me.RadioItem,{ref:r,className:q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(me.ItemIndicator,{children:f.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));yb.displayName=me.RadioItem.displayName;const _b=ye.forwardRef(({className:e,inset:t,...n},r)=>f.jsx(me.Label,{ref:r,className:q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));_b.displayName=me.Label.displayName;const Ab=ye.forwardRef(({className:e,...t},n)=>f.jsx(me.Separator,{ref:n,className:q("-mx-1 my-1 h-px bg-muted",e),...t}));Ab.displayName=me.Separator.displayName;function Xo({className:e,...t}){return f.jsx("div",{className:q("animate-pulse rounded-md bg-secondary",e),...t})}function Cb(){const e=Bt(),[t,n]=X.useState(!1),{toChatScreen:r}=W.useWidgetRouter();return f.jsxs(gb,{open:t,onOpenChange:n,children:[f.jsx(bb,{asChild:!0,children:f.jsx(Oe,{variant:"ghost",size:"fit",className:"rounded-full",children:f.jsx(le.EllipsisVerticalIcon,{className:"size-4"})})}),f.jsx(Go,{align:"end",className:"min-w-56",children:f.jsx(Eb,{children:f.jsxs(Qo,{onSelect:()=>{n(!1),r()},children:[f.jsx(be.motion.div,{initial:{opacity:0,x:-4,rotate:360},animate:{opacity:1,x:0,rotate:0},children:f.jsx(le.MessageCirclePlusIcon,{})}),e.get("new-conversation")]})})})]})}function kb(){const{setIsOpen:e}=W.useWidgetTrigger(),{isSmallScreen:t}=Mt();return t?f.jsx(Oe,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>e(!1),children:f.jsx(le.XIcon,{className:"size-4"})}):null}function Nb(){var i;const{data:e}=W.usePreludeData(),{routerState:{screen:t}}=W.useWidgetRouter(),{textContent:n}=W.useConfig();return(()=>{var a,s;switch(t){case"chat":return(a=n==null?void 0:n.chatScreen)==null?void 0:a.headerTitle;case"sessions":return(s=n==null?void 0:n.sessionsScreen)==null?void 0:s.headerTitle;case"welcome":return;default:return}})()??((i=e==null?void 0:e.data)==null?void 0:i.organizationName)??"Chat"}function Ko(){const{routerState:{screen:e},toSessionsScreen:t}=W.useWidgetRouter(),{isLoading:n}=W.usePreludeData(),r=ii(),i=(()=>{switch(e){case"chat":return re("chat/header");case"sessions":return re("sessions/header");case"welcome":return;default:return}})(),a=Nb();return f.jsx("header",{...i,className:"py-2 px-4 shrink-0",children:f.jsxs("div",{dir:r,className:"flex items-center rtl:flex-row-reverse gap-2",children:[e==="chat"&&f.jsx(Oe,{variant:"ghost",size:"fit",className:"rounded-full",onClick:t,children:f.jsx(le.ChevronLeftIcon,{className:"size-4"})}),f.jsx("div",{className:q("flex-1",e==="sessions"&&"pl-2"),children:f.jsx(be.AnimatePresence,{mode:"wait",children:n?f.jsx(ae,{snapExit:!0,children:f.jsx(Xo,{className:"h-5 w-1/2"})},"skeleton"):f.jsx(ae,{children:f.jsx("h2",{className:"font-semibold",children:a})},"organization-name")})}),f.jsx(Cb,{}),f.jsx(kb,{})]})})}function Ib({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...r}){const{componentStore:i}=W.useWidget();if(r.data.action){const s=i.getComponent(r.data.action.name);if(s)return f.jsx(s,{...r,id:r.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const a=i.getComponent(r.component);return a?f.jsx(a,{...r,id:r.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):f.jsx(Rn,{...r,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function Da({messages:e,agent:t,suggestedReplies:n}){return f.jsxs("div",{...re("chat/agent_msg_group/root"),className:q("flex items-end gap-2"),children:[f.jsx(an,{content:t==null?void 0:t.name,side:"right",align:"end",children:f.jsx(Lr,{...re("chat/agent_msg_group/root/avatar"),agent:t,className:"hidden"})}),f.jsxs("div",{className:q("flex-1 flex flex-col gap-2"),children:[f.jsxs("div",{...re("chat/agent_msg_group/avatar_and_msgs/root"),className:q("flex items-end gap-2"),children:[f.jsx(an,{content:t==null?void 0:t.name,side:"right",align:"end",children:f.jsx(Lr,{...re("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),f.jsx("div",{...re("chat/agent_msg_group/avatar_and_msgs/msgs"),className:q("flex-1 flex flex-col gap-1"),children:e.map((r,i,a)=>f.jsx(Ib,{isFirstInGroup:i===0,isLastInGroup:i===a.length-1,isAloneInGroup:a.length===1,...r},r.id))})]}),f.jsx("div",{...re("chat/agent_msg_group/suggestions"),className:q("flex flex-col gap-1 pl-8"),children:n==null?void 0:n.map((r,i)=>f.jsx(ai,{suggestion:r},`${r}-${i}`))})]})]})}function Sb({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:r}){var i;return f.jsxs("div",{...re("chat/user_msg/root"),className:"w-5/6 flex flex-col items-end gap-1",children:[e.attachments&&e.attachments.length>0&&f.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(i=e.attachments)==null?void 0:i.map(a=>f.jsx(Yo,{attachment:a},a.id))}),e.content.length>0&&f.jsx("div",{...re("chat/user_msg/msg"),"data-first":t,"data-last":n,"data-alone":r,className:q("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground","break-words [word-break:break-word]","whitespace-pre-wrap",t&&!r&&"rounded-br-md",n&&!r&&"rounded-tr-md",!t&&!n&&!r&&"rounded-r-md"),children:e.content})]})}function Ob({messages:e}){return f.jsx("div",{...re("chat/user_msg_group/root"),className:q("group","flex flex-col gap-1 justify-end items-end"),children:e.map((t,n,r)=>f.jsx(Sb,{message:t,isFirstInGroup:n===0,isLastInGroup:n===r.length-1,isAloneInGroup:r.length===1},t.id))})}function Lb(e){const t=[];let n=null;return e.forEach(r=>{var i,a,s,u;(!n||((i=n[0])==null?void 0:i.type)!==r.type)&&(n=[],t.push(n)),((a=n[0])==null?void 0:a.type)==="FROM_AGENT"&&r.type==="FROM_AGENT"&&((s=r.agent)==null?void 0:s.id)!==((u=n[0].agent)==null?void 0:u.id)&&(n=[],t.push(n)),n.push(r)}),t}function Rb(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="FROM_USER"}function Db(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="FROM_BOT"}function vb(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="FROM_AGENT"}function Pb(){const{messagesState:{messages:e}}=W.useMessages(),{isAwaitingBotReply:t}=W.useIsAwaitingBotReply(),{componentStore:n}=W.useWidget(),r=W.useConfig(),{initialQuestions:i,initialQuestionsPosition:a}=r,s=X.useMemo(()=>Lb(e),[e]),u=r.persistentInitialMessages||[],l=!r.initialMessages||r.initialMessages.length===0?["Hello, how can I help you?"]:r.initialMessages,c=n.getComponent("loading"),d=X.useRef(null);function h(){setTimeout(()=>{const g=d.current;g&&(g.scrollTop=g.scrollHeight)},0)}return X.useEffect(()=>{h()},[e]),f.jsxs("div",{...re("chat/msgs/root"),ref:d,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[f.jsx("div",{...re("chat/persistent_initial_msgs/root"),children:u.map((g,p,E)=>f.jsx(Rn,{component:"bot_message",data:{message:g},id:g,type:"FROM_BOT",timestamp:Date.now().toString(),dataComponentNames:{messageContainer:"chat/persistent_initial_msg/root",message:"chat/persistent_initial_msg/msg"},classNames:{messageContainer:q("w-full flex flex-col items-center text-center"),message:"w-full bg-transparent border-none shadow-none text-xs"},isFirstInGroup:p===0,isLastInGroup:p===E.length-1,isAloneInGroup:E.length===1},`${g}-${p}`))}),e.length===0&&f.jsx(Da,{messages:l.map((g,p)=>({component:"bot_message",data:{message:g},id:`${g}-${p}`,type:"FROM_BOT",timestamp:Date.now().toString()})),suggestedReplies:a==="below-initial-messages"?i:void 0,agent:r.bot?{...r.bot,isAi:!0,id:null}:void 0}),s.map(g=>{var y,k,_;const p=(y=g==null?void 0:g[0])==null?void 0:y.type,E=(k=g[0])==null?void 0:k.id;if(!p||!E)return null;if(Rb(g))return f.jsx(Ob,{messages:g},E);if(Db(g)||vb(g)){const S=(_=g[0])==null?void 0:_.agent;return f.jsx(Da,{messages:g,agent:S},E)}return null}),t&&c&&f.jsx(c,{agent:r.bot})]})}function $o({className:e}){return f.jsx(le.LoaderIcon,{className:q("size-4 animate-spin",e)})}function si({width:e,height:t}){const{isSmallScreen:n}=Mt(),{contentIframeRef:r}=W.useWidget();X.useEffect(()=>{var i,a;e&&((i=r==null?void 0:r.current)==null||i.style.setProperty("--opencx-widget-width",e)),t&&((a=r==null?void 0:r.current)==null||a.style.setProperty("--opencx-widget-height",t))},[n,t,e,r])}function Mb(){const{messagesState:{isInitialFetchLoading:e}}=W.useMessages(),{sessionState:{session:t}}=W.useSessions(),{theme:n}=fn();si({width:n.screens.chat.width,height:n.screens.chat.height});const r=X.useRef((t==null?void 0:t.id)||"chat").current;return f.jsx("div",{...re("chat/root"),className:q("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:f.jsxs("div",{className:"size-full justify-between flex flex-col",children:[f.jsx(Ko,{}),f.jsx(be.AnimatePresence,{mode:"wait",children:e?f.jsx(ae,{className:"flex flex-col items-center justify-center w-full flex-1",children:f.jsx($o,{})},"loading"):f.jsxs(ae,{className:"flex flex-col w-full flex-1 overflow-auto",snapExit:!0,children:[f.jsx(Pb,{}),f.jsx(mb,{})]},r)})]})})}const An=ye.forwardRef(({className:e,type:t,...n},r)=>{const{isSmallScreen:i}=Mt(),a=ii();return f.jsx($e,{ref:r,children:f.jsx("input",{dir:a,type:t,className:q(i?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rtl:placeholder:text-right","bg-white","rounded-3xl px-4",e),...n})})});An.displayName="Input";function Bb({className:e}){return f.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:q("text-primary-foreground",e),children:f.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function Jo({className:e}){const{token:t}=W.useConfig();return f.jsx("div",{className:q("flex items-center justify-center gap-2 p-2 pt-0 bg-background",e),children:f.jsx($e,{children:f.jsxs("a",{href:`https://open.cx/?ref=${t}`,target:"_blank",rel:"noreferrer",className:q("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[f.jsx("span",{children:"Powered by"}),f.jsx("span",{children:" "}),f.jsxs("span",{className:"flex items-center gap-[1px]",children:[f.jsx("span",{children:f.jsx(Bb,{className:"size-3 inline-block"})}),f.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function Fb(){const{contentIframeRef:e}=W.useWidget(),t=X.useRef(null);return X.useEffect(()=>{const n=e==null?void 0:e.current;if(n&&t.current){const r=t.current;let i;const a=new ResizeObserver(()=>{i=requestAnimationFrame(()=>{const s=r.offsetHeight;n.style.setProperty("--opencx-widget-height",`${s.toFixed(1)}px`)})});return a.observe(r),()=>{cancelAnimationFrame(i),a.unobserve(r)}}},[e]),{observedElementRef:t}}const Hb=Gn.z.object({name:Gn.z.string().min(2),email:Gn.z.string().email()});function Ub(){var _,S,L,M,F,I,j,U,z;const{setIsOpen:e}=W.useWidgetTrigger(),{createUnverifiedContact:t}=W.useContact(),{isSmallScreen:n}=Mt(),r=W.useConfig(),{theme:i}=fn(),a=Bt(),{data:s}=W.usePreludeData(),{observedElementRef:u}=Fb();si({height:void 0,width:i.screens.welcome.width});const[l,c]=X.useState(((_=r.prefillUserData)==null?void 0:_.name)||""),[d,h]=X.useState(((S=r.prefillUserData)==null?void 0:S.email)||""),g=(r.extraDataCollectionFields||[]).filter(C=>C!=="name"&&C!=="email"&&!!C),[p,E]=X.useState({}),[y,k]=W._default(async C=>{C.preventDefault();const H=Hb.safeParse({name:l,email:d});H.success&&await t({email:H.data.email,non_verified_name:H.data.name},Object.values(p).filter(Boolean).length?p:void 0)},[l,d,p]);return f.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:i.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:f.jsxs("div",{ref:u,className:q("flex flex-col",n&&"h-full"),children:[f.jsxs("div",{dir:"auto",className:"flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10",children:[n&&f.jsx(ae,{className:"absolute top-6 right-6",children:f.jsx(Oe,{size:"selfless",onClick:()=>e(!1),children:f.jsx(le.XIcon,{className:"size-4"})})}),f.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(L=r.assets)!=null&&L.organizationLogo?f.jsx("img",{src:(M=r.assets)==null?void 0:M.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):f.jsx("h2",{className:"font-bold text-xl",dir:"auto",children:(F=s==null?void 0:s.data)==null?void 0:F.organizationName})}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("h1",{className:"text-2xl font-bold",dir:"auto",children:((j=(I=r.textContent)==null?void 0:I.welcomeScreen)==null?void 0:j.title)||a.get("welcome-title")}),f.jsx("p",{className:"/90 text-sm max-w-[320px] leading-relaxed",dir:"auto",children:((z=(U=r.textContent)==null?void 0:U.welcomeScreen)==null?void 0:z.description)||a.get("welcome-description")})]})]}),f.jsxs("div",{className:"z-10 px-2 pt-2 bp-0 bg-background space-y-2",dir:"auto",children:[f.jsxs("form",{onSubmit:k,className:"space-y-2",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(An,{value:l,onChange:C=>c(C.target.value),required:!0,placeholder:a.get("your-name"),name:"name"}),f.jsx(An,{required:!0,value:d,onChange:C=>h(C.target.value),type:"email",placeholder:a.get("your-email"),name:"email"}),g.map(C=>f.jsx(An,{value:p[C],onChange:H=>E(P=>({...P,[C]:H.target.value})),placeholder:`${C} (${a.get("optional")})`},C))]}),f.jsxs(Oe,{disabled:y.loading,className:"w-full rounded-3xl",size:"lg",children:[y.loading?a.get("starting-chat"):a.get("start-chat"),f.jsx(le.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),f.jsx(Jo,{})]})]})})}function zb({session:e}){const{bot:t}=W.useConfig(),{toChatScreen:n}=W.useWidgetRouter(),r=e.assignee.kind==="human"?e.assignee.name||"Support Agent":(t==null?void 0:t.name)||"AI Support Agent",i=e.assignee.kind==="human"?e.assignee.avatarUrl||"":(t==null?void 0:t.avatar)||"";return f.jsxs(Oe,{variant:"ghost",size:"lg",className:"rounded-full p-2 pr-4 flex text-start justify-between w-full whitespace-normal",onClick:()=>n(e.id),children:[f.jsxs("div",{className:"flex-1 flex gap-2 items-center",children:[f.jsx(be.AnimatePresence,{mode:"wait",children:f.jsx(ae,{snapExit:!0,children:f.jsxs(ti,{className:"size-10",children:[f.jsx(ni,{src:i,alt:"Agent Icon"}),f.jsx(ri,{children:f.jsx(le.UserRoundIcon,{className:"size-4"})})]})})}),f.jsxs("div",{className:"flex-1",children:[f.jsx(be.AnimatePresence,{mode:"wait",children:f.jsx(ae,{snapExit:!0,children:r},r)}),f.jsx(be.AnimatePresence,{mode:"wait",children:e.lastMessage?f.jsx(ae,{snapExit:!0,children:f.jsx(Ws,{remarkPlugins:[gs],rehypePlugins:[Oo],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):f.jsx(ae,{className:"w-1/2",snapExit:!0,children:f.jsx(Xo,{className:"h-4 w-full"})},"skeleton")})]})]}),f.jsx(le.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0"})]})}function jb(){const e=Bt(),{toChatScreen:t}=W.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:r}}=W.useSessions();return f.jsx("div",{className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:f.jsx(be.AnimatePresence,{mode:"wait",children:r?f.jsx(ae,{className:"flex-1 flex items-center justify-center",children:f.jsx($o,{})},"loading"):f.jsx(ae,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?f.jsxs(f.Fragment,{children:[f.jsx(be.AnimatePresence,{children:n.map((i,a)=>f.jsx(ae,{snapExit:!0,children:f.jsx(zb,{session:i})},`${i.id}-${a}`))}),f.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:X.createElement(Oe,{...re("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full rounded-3xl",onClick:()=>t()},e.get("new-conversation"))})]}):f.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[f.jsx("div",{className:"flex-1 flex items-center justify-center",children:f.jsx("p",{className:"text-muted-foreground",children:e.get("no-conversations-yet")})}),X.createElement(Oe,{...re("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full rounded-3xl",onClick:()=>t()},e.get("new-conversation"))]})},"sessions")})})}function Yb(){const{theme:e}=fn();return si({width:e.screens.sessions.width,height:e.screens.sessions.height}),f.jsxs("div",{...re("sessions/root"),className:q("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[f.jsxs("div",{className:"size-full flex flex-col",children:[f.jsx(Ko,{}),f.jsx(jb,{})]}),f.jsx(Jo,{})]})}function Wb(){W.usePreludeData();const{routerState:{screen:e}}=W.useWidgetRouter();return f.jsxs("div",{className:"relative bg-background size-full",children:[f.jsx(Vn.Container,{}),f.jsx(be.AnimatePresence,{mode:"wait",children:(()=>{switch(e){case"welcome":return f.jsx(ae,{fadeIn:"right",className:"size-full",snapExit:!0,children:f.jsx(Ub,{})},e);case"sessions":return f.jsx(ae,{fadeIn:"right",className:"size-full",snapExit:!0,children:f.jsx(Yb,{})},e);case"chat":return f.jsx(ae,{fadeIn:"right",className:"size-full",snapExit:!0,children:f.jsx(Mb,{})},e);default:return null}})()})]})}const qb=`<!DOCTYPE html>
45
+ )`)};return{theme:i,computed:a,cssVars:eb({palette:i.palette,primary:i.primaryColor})}}function eb({palette:e,primary:t}){const n=tb(e),r=hi(t).toHsl(),i=hi(t).isLight()?n[950]:n[50];return{"--opencx-primary":`${r.h} ${r.s*100}% ${r.l*100}%`,"--opencx-primary-foreground":i,"--opencx-background":n[100],"--opencx-foreground":n[950],"--opencx-destructive":"0 72.2% 50.6%","--opencx-destructive-foreground":n[50],"--opencx-accent":n[200],"--opencx-accent-foreground":"var(--opencx-foreground)","--opencx-secondary":n[200],"--opencx-secondary-foreground":"var(--opencx-foreground)","--opencx-muted":n[200],"--opencx-muted-foreground":n[500],"--opencx-input":n[300],"--opencx-border":n[300],"--opencx-ring":"var(--opencx-foreground)"}}function tb(e){const t={50:"0 0% 98%",100:"0 0% 96.1%",200:"0 0% 89.8%",300:"0 0% 83.1%",400:"0 0% 63.9%",500:"0 0% 45.1%",600:"0 0% 32.2%",700:"0 0% 25.1%",800:"0 0% 14.9%",900:"0 0% 9%",950:"0 0% 3.9%"},n={50:"60 9.1% 97.8%",100:"60 4.8% 95.9%",200:"20 5.9% 90%",300:"24 5.7% 82.9%",400:"24 5.4% 63.9%",500:"25 5.3% 44.7%",600:"33.3 5.5% 32.4%",700:"30 6.3% 25.1%",800:"12 6.5% 15.1%",900:"24 9.8% 10%",950:"20 14.3% 4.1%"},r={50:"0 0% 98%",100:"240 4.8% 95.9%",200:"240 5.9% 90%",300:"240 4.9% 83.9%",400:"240 5% 64.9%",500:"240 3.8% 46.1%",600:"240 5.2% 33.9%",700:"240 5.3% 26.1%",800:"240 3.7% 15.9%",900:"240 5.9% 10%",950:"240 10% 3.9%"},i={50:"210 40% 98%",100:"210 40% 96.1%",200:"214.3 31.8% 91.4%",300:"212.7 26.8% 83.9%",400:"215 20.2% 65.1%",500:"215.4 16.3% 46.9%",600:"215.3 19.3% 34.5%",700:"215.3 25% 26.7%",800:"217.2 32.6% 17.5%",900:"222.2 47.4% 11.2%",950:"222.2 84% 4.9%"};switch(e){case"neutral":return t;case"stone":return n;case"zinc":return r;case"slate":return i;default:return t}}const ii=()=>{const[e,t]=X.useState("ltr");return X.useEffect(()=>{const n=()=>{typeof document>"u"||t(window.getComputedStyle(document.body).direction)};n();const r=new MutationObserver(n);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),r.observe(document.body,{attributes:!0,attributeFilter:["dir"]}),window.addEventListener("languagechange",n),()=>{r.disconnect(),window.removeEventListener("languagechange",n)}},[]),e},nb={ok:"حسنا",yes:"نعم",no:"لا",agree:"موافق",cancel:"إلغاء","yes-exit":"نعم، اخرج","yes-reset":"نعم، إعادة تعيين","no-cancel":"لا، إلغاء","are-you-sure":"هل أنت متأكد؟",recording:"تسجيل","thank-you":"شكرا","sorry-try-again":"عذرا، حاول مرة أخرى","error-occurred":"حدث خطأ","please-try-again":"يرجى المحاولة مرة أخرى","write-a-message":"اكتب رسالة...","send-message":"إرسال رسالة",connected:"متصل",connecting:"جاري الاتصال",reconnecting:"جاري إعادة الاتصال",reconnected:"تم إعادة الاتصال",disconnecting:"جاري قطع الاتصال",disconnected:"قطع الاتصال",error:"خطأ","persist-session":"حفظ الجلسة",settings:"إعدادات",close:"إغلاق",help:"مساعدة",chat:"محادثة",send:"إرسال",copy:"نسخ",copied:"تم النسخ","sound-effects":"التاثيرات الصوتية",language:"اللغة",select:"اختر",agent:"الوكيل",user:"المستخدم",bot:"البوت","close-widget":"إغلاق الودجة","got-any-questions":"هل لديك أي أسئلة؟ تحدث معنا!","typical-response-time":"عادة ما نرد في أقل من دقيقة واحدة","session-closed-lead":"تم حل مشكلتك!",exit:"خروج","create-new-ticket":"إنشاء تذكرة جديدة","reset-conversation":"إعادة تعيين المحادثة","new-conversation":"محادثة جديدة","welcome-title":"مرحبًا بك في دردشة الدعم الخاصة بنا","welcome-description":"نحن هنا للمساعدة! ابدأ محادثة وسنرد عليك في أقرب وقت ممكن.","your-name":"اسمك","your-email":"عنوان بريدك الإلكتروني","start-chat":"تحدث إلى الدعم","starting-chat":"جاري الاتصال...","hello-greeting":"مرحبًا! كيف يمكننا مساعدتك اليوم؟","i-need-more-help":"أحتاج المزيد من المساعدة","this-was-helpful":"كان هذا مفيدًا",optional:"اختياري","no-conversations-yet":"لا يوجد محادثات"},rb={ok:"OK",yes:"Ja",no:"Nein",agree:"Zustimmen",cancel:"Stornieren","yes-exit":"Ja, beenden","yes-reset":"Ja, zurücksetzen","no-cancel":"Nein, abbrechen","are-you-sure":"Sind Sie sicher?",recording:"Aufnahme läuft","thank-you":"Vielen Dank","sorry-try-again":"Entschuldigung, bitte versuchen Sie es erneut","error-occurred":"Ein Fehler ist aufgetreten","please-try-again":"Bitte versuchen Sie es erneut","write-a-message":"Nachricht schreiben...","send-message":"Nachricht senden",connected:"Verbunden",connecting:"Verbindung wird hergestellt",reconnecting:"Verbindung wird wiederhergestellt",reconnected:"Wieder verbunden",disconnecting:"Verbindung wird getrennt",disconnected:"Verbindung getrennt",error:"Fehler","persist-session":"Sitzung beibehalten",settings:"Einstellungen",close:"Schließen",help:"Hilfe",chat:"Chat",send:"Senden",copy:"Kopieren",copied:"Kopiert","sound-effects":"Soundeffekte",language:"Sprache",select:"Auswählen",agent:"Agent",user:"Benutzer",bot:"Bot","got-any-questions":"Haben Sie Fragen? Chatten Sie mit uns!","typical-response-time":"Üblicherweise antworten wir in weniger als 1 Minute","close-widget":"Widget schließen","session-closed-lead":"Ihr Problem wurde gelöst!","create-new-ticket":"Neues Ticket erstellen",exit:"Beenden","reset-conversation":"Konversation zurücksetzen","new-conversation":"Neue Konversation","welcome-title":"Willkommen in unserem Support-Chat","welcome-description":"Wir sind hier, um zu helfen! Beginnen Sie ein Gesprách und wir werden so schnell wie mogelijk antworten.","your-name":"Ihr Name","your-email":"Ihre E-Mail-Adresse","start-chat":"Mit dem Support sprechen","starting-chat":"Verbindung wird hergestellt...","hello-greeting":"Hallo! Wie können wir Ihnen heute helfen?","i-need-more-help":"Ich brauche weitere Hilfe","this-was-helpful":"Dies war hilfreich",optional:"Optional","no-conversations-yet":"noch keine Gespräche"},ib={ok:"OK",yes:"Yes",no:"No",agree:"Agree",cancel:"Cancel","yes-exit":"Yes, exit","yes-reset":"Yes, reset","no-cancel":"No, cancel","are-you-sure":"Are you sure?",recording:"Recording...","thank-you":"Thank you","sorry-try-again":"Sorry, please try again","error-occurred":"An error occurred","please-try-again":"Please try again","write-a-message":"Write a message...","send-message":"Send message",connected:"Connected",connecting:"Connecting",reconnecting:"Reconnecting",reconnected:"Reconnected",disconnecting:"Disconnecting",disconnected:"Disconnected",error:"Error","persist-session":"Persist session",settings:"Settings",close:"Close",help:"Help",chat:"Chat",send:"Send",copy:"Copy",copied:"Copied","sound-effects":"Sound effects",language:"Language",select:"Select",agent:"Agent",user:"User",bot:"Bot","close-widget":"Close widget","got-any-questions":"Got any questions? Chat with us!","typical-response-time":"Typically respond in less than 1 minute","session-closed-lead":"Your issue has been resolved!","create-new-ticket":"Create new ticket",exit:"Exit","reset-conversation":"Reset conversation","new-conversation":"New conversation","welcome-title":"Welcome to our support chat","welcome-description":"We're here to help! Start a conversation and we'll get back to you as soon as possible.","your-name":"Your name","your-email":"Your email address","start-chat":"Talk to support","starting-chat":"Connecting...","hello-greeting":"Hi there!","i-need-more-help":"I need more help","this-was-helpful":"This was helpful",optional:"Optional","no-conversations-yet":"No conversations yet"},ab={ok:"D'accord",yes:"Oui",no:"Non",agree:"Accepter",cancel:"Annuler","yes-exit":"Oui, quitter","yes-reset":"Oui, réinitialiser","no-cancel":"Non, annuler","are-you-sure":"Êtes-vous sûr ?",recording:"Enregistrement...","thank-you":"Merci","sorry-try-again":"Désolé, veuillez réessayer","error-occurred":"Une erreur s'est produite","please-try-again":"Veuillez réessayer","write-a-message":"Écrivez un message...","send-message":"Envoyer le message",connected:"Connecté",connecting:"Connexion en cours",reconnecting:"Reconnexion en cours",reconnected:"Reconnecté",disconnecting:"Déconnexion en cours",disconnected:"Déconnecté",error:"Erreur","persist-session":"Conserver la session",settings:"Paramètres",close:"Fermer",help:"Aide",chat:"Chat",send:"Envoyer",copy:"Copier",copied:"Copié","sound-effects":"Effets sonores",language:"Langue",select:"Sélectionner",agent:"Agent",user:"Utilisateur",bot:"Bot","close-widget":"Fermer le widget","got-any-questions":"Vous avez des questions ? Chattez avec nous !","typical-response-time":"Nous répondons généralement en moins d'une minute","session-closed-lead":"Votre problème a été résolu !","create-new-ticket":"Créer un nouveau ticket",exit:"Sortie","reset-conversation":"Réinitialiser la conversation","new-conversation":"Nouvelle conversation","welcome-title":"Bienvenue dans notre chat de support","welcome-description":"Nous sommes là pour vous aider ! Commencez une conversation et nous vous répondrons dès que possible.","your-name":"Votre nom","your-email":"Votre adresse e-mail","start-chat":"Parler au support","starting-chat":"Connexion...","hello-greeting":"Bonjour ! Comment pouvons-nous vous aider aujourd'hui ?","i-need-more-help":"Je besoin d'aide plus","this-was-helpful":"C'était utile",optional:"Optionnel","no-conversations-yet":"Aucune conversation pour le moment"},sb={ok:"OK",yes:"Ja",no:"Nee",agree:"Akkoord",cancel:"Annuleren","yes-exit":"Ja, afsluiten","yes-reset":"Ja, resetten","no-cancel":"Nee, annuleren","are-you-sure":"Weet u het zeker?",recording:"Opname...","thank-you":"Dank u","sorry-try-again":"Sorry, probeer het opnieuw","error-occurred":"Er is een fout opgetreden","please-try-again":"Probeer het opnieuw","write-a-message":"Schrijf een bericht...","send-message":"Bericht verzenden",connected:"Verbonden",connecting:"Verbinding maken",reconnecting:"Opnieuw verbinding maken",reconnected:"Opnieuw verbonden",disconnecting:"Verbinding verbreken",disconnected:"Verbinding verbroken",error:"Fout","persist-session":"Sessie behouden",settings:"Instellingen",close:"Sluiten",help:"Help",chat:"Chat",send:"Verzenden",copy:"Kopiëren",copied:"Gekopieerd","sound-effects":"Geluidseffecten",language:"Taal",select:"Selecteren",agent:"Agent",user:"Gebruiker",bot:"Bot","close-widget":"Widget sluiten","got-any-questions":"Heeft u vragen? Chat met ons!","typical-response-time":"We reageren doorgaans binnen 1 minuut","session-closed-lead":"Uw probleem is opgelost!","create-new-ticket":"Nieuw ticket aanmaken",exit:"Afsluiten","reset-conversation":"Gesprek resetten","new-conversation":"Nieuw gesprek","welcome-title":"Welkom bij onze supportchat","welcome-description":"We zijn hier om te helpen! Begin een gesprek en we nemen zo snel mogelijk contact met u op.","your-name":"Uw naam","your-email":"Uw e-mailadres","start-chat":"Praat met ondersteuning","starting-chat":"Verbinding maken...","hello-greeting":"Hallo! Hoe kunnen we u vandaag helpen?","i-need-more-help":"Ik heb nog meer hulp nodig","this-was-helpful":"Mijn vraag is opgelost",optional:"Optioneel","no-conversations-yet":"Nog geen gesprekken"},ob={ok:"OK",yes:"Sim",no:"Não",agree:"Concordo",cancel:"Cancelar","yes-exit":"Sim, sair","yes-reset":"Sim, redefinir","no-cancel":"Não, cancelar","are-you-sure":"Você tem certeza?",recording:"Gravando...","thank-you":"Obrigado","sorry-try-again":"Desculpe, tente novamente","error-occurred":"Ocorreu um erro","please-try-again":"Por favor, tente novamente","write-a-message":"Escreva uma mensagem...","send-message":"Enviar mensagem",connected:"Conectado",connecting:"Conectando",reconnecting:"Reconectando",reconnected:"Reconectado",disconnecting:"Desconectando",disconnected:"Desconectado",error:"Erro","persist-session":"Persistir sessão",settings:"Configurações",close:"Fechar",help:"Ajuda",chat:"Bate-papo",send:"Enviar",copy:"Copiar",copied:"Copiado","sound-effects":"Efeitos sonoros",language:"Idioma",select:"Selecionar",agent:"Agente",user:"Usuário",bot:"Bot","close-widget":"Fechar widget","got-any-questions":"Tem alguma dúvida? Converse conosco!","typical-response-time":"Geralmente respondemos em menos de 1 minuto","session-closed-lead":"Seu problema foi resolvido!","create-new-ticket":"Criar novo ticket",exit:"Sair","reset-conversation":"Redefinir conversa","new-conversation":"Nova conversa","welcome-title":"Bem-vindo ao nosso chat de suporte","welcome-description":"Estamos aqui para ajudar! Inicie uma conversa e responderemos o mais rápido possível.","your-name":"Seu nome","your-email":"Seu endereço de email","start-chat":"Falar com o suporte","starting-chat":"Conectando...","hello-greeting":"Olá! Como podemos ajudar você hoje?","i-need-more-help":"preciso de mais ajuda","this-was-helpful":"Isso foi útil",optional:"Opcional","no-conversations-yet":"Nenhuma conversa ainda"},Vo={en:ib,ar:nb,nl:sb,fr:ab,de:rb,pt:ob},ub=Object.keys(Vo),lb=e=>ub.includes(e);function cb(e,t){const n=Vo[t];return n&&n[e]||""}function Bt(){const{widgetCtx:{config:e}}=W.useWidget();return X.useMemo(()=>{const n=lb(e.language)?e.language:"en";return{get:r=>cb(r,n),lang:n}},[e.language])}function ai({suggestion:e,className:t,...n}){const{sendMessage:r}=W.useMessages(),i=()=>{const a=e.trim();a&&r({content:a})};return f.jsx(Oe,{...re("chat/suggested_reply_btn"),size:"sm",className:q("rounded-xl w-fit",t),...n,onClick:i,children:e})}function db(){const e=Bt(),t=[e.get("i-need-more-help"),e.get("this-was-helpful")];return f.jsx("div",{...re("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:t.map(n=>f.jsx(ai,{suggestion:n,className:"flex-1"},n))})}function hb({file:{status:e,file:t,error:n},onCancel:r}){const[i,a]=X.useState(null);X.useEffect(()=>{if(!t.type.startsWith("image/"))return;const l=new FileReader;return l.onload=()=>a(l.result),l.onerror=()=>console.error("Error reading file"),l.readAsDataURL(t),()=>l.abort()},[t]);const s=()=>{switch(e){case"uploading":return f.jsx(le.Loader2,{className:"size-4 animate-spin"});case"error":return f.jsx(le.AlertCircle,{className:"size-4 text-destructive"});default:return null}},u=()=>{const l=t.type.split("/")[0];return l==="image"&&i?f.jsx("img",{src:typeof i=="string"?i:"",className:"object-cover bg-secondary size-full",alt:t.name}):l==="audio"?f.jsx(le.FileAudio2Icon,{}):l==="video"?f.jsx(le.FileVideo2Icon,{}):f.jsx(le.FileIcon,{})};return f.jsx(an,{side:"bottom",content:e==="error"?f.jsxs("span",{className:"text-destructive",children:["Failed to upload: ",n]}):t.name,children:f.jsxs("div",{className:q(e==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s()}),f.jsx("button",{type:"button",className:q("absolute bg-black/50 inset-0 size-full z-10 opacity-0","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:r,children:f.jsx(le.XIcon,{className:"size-4 text-primary-foreground"})}),f.jsx(u,{})]})})}function fb(){var j;const{isSmallScreen:e}=Mt(),t=X.useRef(null),{sendMessage:n}=W.useMessages(),{sessionState:r}=W.useSessions(),i=Bt(),a=ii(),[s,u]=X.useState(""),{allFiles:l,emptyTheFiles:c,handleCancelUpload:d,appendFiles:h,isUploading:g,successFiles:p}=W.useUploadFiles(),E=!!((j=r.session)!=null&&j.isHandedOff),{isAwaitingBotReply:y}=W.useIsAwaitingBotReply(),k=U=>{h(U)},_=!s.trim()&&p.length===0,S=async()=>{if(y||_)return;g&&console.info("please wait for the file(s) to upload");const U=s.trim();n({content:U,attachments:p.flatMap(z=>z.fileUrl?[{url:z.fileUrl,type:z.file.type,name:z.file.name,id:z.id,size:z.file.size}]:[])}),u(""),c()},{getRootProps:L,getInputProps:M,open:F}=fu.useDropzone({onDrop:k,noClick:!0,onDropRejected(){console.error("unsupported file type, or the file is too large")},maxSize:5*1024*1024,accept:E?{"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],"application/pdf":[".pdf"]}:{"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]}}),I=U=>{const z=U.clipboardData;z&&z.files.length>0&&k(Array.from(z.files))};return f.jsxs("div",{...re("chat/input_box/root"),className:"p-2 relative space-y-1",...L(),children:[f.jsx("input",{...M()}),f.jsxs("div",{...re("chat/input_box/inner_root"),className:q("transition-all","bg-white","relative rounded-3xl flex flex-col gap-2 p-2","hover:border-primary focus-within:border-primary"),children:[f.jsxs("div",{...re("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[l.length>0&&f.jsx("div",{...re("chat/input_box/attachments_container"),className:"flex items-center gap-1",children:f.jsx(be.AnimatePresence,{mode:"popLayout",children:l.map(U=>f.jsx(ae,{snapExit:!0,children:f.jsx(hb,{onCancel:()=>d(U.id),file:U})},U.id))})}),f.jsx("textarea",{...re("chat/input_box/textarea"),onPaste:I,ref:t,id:"chat-input",dir:a,value:s,rows:3,className:q("max-h-16 [field-sizing:content]","w-full resize-none px-2",l.length===0&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground","rtl:placeholder:text-right",e?"text-[16px]":"text-sm"),onChange:U=>u(U.target.value),onKeyDown:async U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),S())},placeholder:i.get("write-a-message")})]}),f.jsxs("div",{dir:a,className:"gap-2 flex justify-between rtl:text-right",children:[f.jsx(an,{side:"top",align:"start",content:"attach files, (maximum size 5mb)",children:f.jsx(Oe,{onClick:F,size:"fit",variant:"ghost",className:q("rounded-full size-8 flex items-center justify-center p-0 overflow-hidden"),children:f.jsx(be.AnimatePresence,{mode:"wait",children:E?f.jsx(ae,{children:f.jsx(le.PaperclipIcon,{className:"size-4"})},"paper-clip"):f.jsx(ae,{children:f.jsx(le.ImageIcon,{className:"size-4"})},"image-icon")})})}),f.jsx(an,{content:"send message",side:"top",align:"end",children:f.jsx(Oe,{size:"fit",onClick:S,disabled:y||g||_,className:"rounded-full size-8 flex items-center justify-center p-0",children:f.jsx(be.AnimatePresence,{mode:"wait",children:y||g?f.jsx(ae,{snapExit:!0,children:f.jsx(le.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):f.jsx(ae,{snapExit:!0,children:f.jsx(le.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})}function pb(){const{widgetCtx:e}=W.useWidget(),t=Bt();return f.jsx("div",{className:"p-2",children:f.jsxs("div",{className:"p-2 bg-muted rounded-3xl space-y-2",children:[f.jsxs("div",{className:"pl-2 flex items-center gap-1",children:[f.jsx(le.CircleCheckIcon,{className:"size-4 text-emerald-600"}),f.jsx("h2",{className:"text-sm font-medium",dir:"auto",children:t.get("session-closed-lead")})]}),f.jsx("div",{children:f.jsx(Oe,{onClick:e.resetChat,className:"rounded-2xl w-full",children:t.get("new-conversation")})})]})})}function mb(){var a;const{initialQuestions:e,initialQuestionsPosition:t}=W.useConfig(),{sessionState:n}=W.useSessions(),{messagesState:r}=W.useMessages(),i=r.messages.length===0;return f.jsx("footer",{children:f.jsx("div",{children:f.jsx(be.AnimatePresence,{mode:"wait",children:n.session&&!((a=n.session)!=null&&a.isOpened)?f.jsx(ae,{className:"overflow-hidden",overrides:{initial:{height:0},animate:{height:"auto"},exit:{height:0}},children:f.jsx(pb,{})},"session-closed"):f.jsxs(ae,{className:"overflow-hidden",overrides:{initial:{height:0},animate:{height:"auto"},exit:{height:0}},children:[r.lastAIResMightSolveUserIssue&&f.jsx(db,{}),i&&e&&t!=="below-initial-messages"&&f.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:e==null?void 0:e.map((s,u)=>f.jsx(ai,{suggestion:s},`${s}-${u}`))}),f.jsx(fb,{})]},"chat-input")})})})}const gb=me.Root,bb=me.Trigger,Eb=me.Group,Tb=ye.forwardRef(({className:e,inset:t,children:n,...r},i)=>f.jsxs(me.SubTrigger,{ref:i,className:q("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,f.jsx(le.ChevronRight,{className:"ml-auto"})]}));Tb.displayName=me.SubTrigger.displayName;const xb=ye.forwardRef(({className:e,...t},n)=>f.jsx(me.SubContent,{ref:n,className:q("z-50 min-w-[8rem] overflow-hidden rounded-2xl border bg-background p-1 text-foreground shadow-2xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));xb.displayName=me.SubContent.displayName;const Go=ye.forwardRef(({className:e,sideOffset:t=4,...n},r)=>f.jsx(me.Content,{ref:r,sideOffset:t,className:q("z-50 min-w-[8rem] overflow-hidden rounded-2xl border bg-background p-1 text-foreground shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Go.displayName=me.Content.displayName;const Qo=ye.forwardRef(({className:e,inset:t,...n},r)=>f.jsx(ae,{children:f.jsx(me.Item,{ref:r,className:q("relative flex cursor-default select-none items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...n})}));Qo.displayName=me.Item.displayName;const wb=ye.forwardRef(({className:e,children:t,checked:n,...r},i)=>f.jsxs(me.CheckboxItem,{ref:i,className:q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(me.ItemIndicator,{children:f.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));wb.displayName=me.CheckboxItem.displayName;const yb=ye.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(me.RadioItem,{ref:r,className:q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(me.ItemIndicator,{children:f.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));yb.displayName=me.RadioItem.displayName;const _b=ye.forwardRef(({className:e,inset:t,...n},r)=>f.jsx(me.Label,{ref:r,className:q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));_b.displayName=me.Label.displayName;const Ab=ye.forwardRef(({className:e,...t},n)=>f.jsx(me.Separator,{ref:n,className:q("-mx-1 my-1 h-px bg-muted",e),...t}));Ab.displayName=me.Separator.displayName;function Xo({className:e,...t}){return f.jsx("div",{className:q("animate-pulse rounded-md bg-secondary",e),...t})}function Cb(){const e=Bt(),[t,n]=X.useState(!1),{toChatScreen:r}=W.useWidgetRouter();return f.jsxs(gb,{open:t,onOpenChange:n,children:[f.jsx(bb,{asChild:!0,children:f.jsx(Oe,{variant:"ghost",size:"fit",className:"rounded-full",children:f.jsx(le.EllipsisVerticalIcon,{className:"size-4"})})}),f.jsx(Go,{align:"end",className:"min-w-56",children:f.jsx(Eb,{children:f.jsxs(Qo,{onSelect:()=>{n(!1),r()},children:[f.jsx(be.motion.div,{initial:{opacity:0,x:-4,rotate:360},animate:{opacity:1,x:0,rotate:0},children:f.jsx(le.MessageCirclePlusIcon,{})}),e.get("new-conversation")]})})})]})}function kb(){const{setIsOpen:e}=W.useWidgetTrigger(),{isSmallScreen:t}=Mt();return t?f.jsx(Oe,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>e(!1),children:f.jsx(le.XIcon,{className:"size-4"})}):null}function Nb(){var i;const{data:e}=W.usePreludeData(),{routerState:{screen:t}}=W.useWidgetRouter(),{textContent:n}=W.useConfig();return(()=>{var a,s;switch(t){case"chat":return(a=n==null?void 0:n.chatScreen)==null?void 0:a.headerTitle;case"sessions":return(s=n==null?void 0:n.sessionsScreen)==null?void 0:s.headerTitle;case"welcome":return;default:return}})()??((i=e==null?void 0:e.data)==null?void 0:i.organizationName)??"Chat"}function Ko(){const{routerState:{screen:e},toSessionsScreen:t}=W.useWidgetRouter(),{isLoading:n}=W.usePreludeData(),r=ii(),i=(()=>{switch(e){case"chat":return re("chat/header");case"sessions":return re("sessions/header");case"welcome":return;default:return}})(),a=Nb();return f.jsx("header",{...i,className:"py-2 px-4 shrink-0",children:f.jsxs("div",{dir:r,className:"flex items-center rtl:flex-row-reverse gap-2",children:[e==="chat"&&f.jsx(Oe,{variant:"ghost",size:"fit",className:"rounded-full",onClick:t,children:f.jsx(le.ChevronLeftIcon,{className:"size-4"})}),f.jsx("div",{className:q("flex-1",e==="sessions"&&"pl-2"),children:f.jsx(be.AnimatePresence,{mode:"wait",children:n?f.jsx(ae,{snapExit:!0,children:f.jsx(Xo,{className:"h-5 w-1/2"})},"skeleton"):f.jsx(ae,{children:f.jsx("h2",{className:"font-semibold",children:a})},"organization-name")})}),f.jsx(Cb,{}),f.jsx(kb,{})]})})}function Ib({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...r}){const{componentStore:i}=W.useWidget();if(r.data.action){const s=i.getComponent(r.data.action.name);if(s)return f.jsx(s,{...r,id:r.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const a=i.getComponent(r.component);return a?f.jsx(a,{...r,id:r.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):f.jsx(Rn,{...r,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function Da({messages:e,agent:t,suggestedReplies:n}){return f.jsxs("div",{...re("chat/agent_msg_group/root"),className:q("flex items-end gap-2"),children:[f.jsx(an,{content:t==null?void 0:t.name,side:"right",align:"end",children:f.jsx(Lr,{...re("chat/agent_msg_group/root/avatar"),agent:t,className:"hidden"})}),f.jsxs("div",{className:q("flex-1 flex flex-col gap-2"),children:[f.jsxs("div",{...re("chat/agent_msg_group/avatar_and_msgs/root"),className:q("flex items-end gap-2"),children:[f.jsx(an,{content:t==null?void 0:t.name,side:"right",align:"end",children:f.jsx(Lr,{...re("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),f.jsx("div",{...re("chat/agent_msg_group/avatar_and_msgs/msgs"),className:q("flex-1 flex flex-col gap-1"),children:e.map((r,i,a)=>f.jsx(Ib,{isFirstInGroup:i===0,isLastInGroup:i===a.length-1,isAloneInGroup:a.length===1,...r},r.id))})]}),n&&n.length>0&&f.jsx("div",{...re("chat/agent_msg_group/suggestions"),className:q("flex flex-col gap-1 pl-8"),children:n==null?void 0:n.map((r,i)=>f.jsx(ai,{suggestion:r},`${r}-${i}`))})]})]})}function Sb({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:r}){var i;return f.jsxs("div",{...re("chat/user_msg/root"),className:"w-5/6 flex flex-col items-end gap-1",children:[e.attachments&&e.attachments.length>0&&f.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(i=e.attachments)==null?void 0:i.map(a=>f.jsx(Yo,{attachment:a},a.id))}),e.content.length>0&&f.jsx("div",{...re("chat/user_msg/msg"),"data-first":t,"data-last":n,"data-alone":r,className:q("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground","break-words [word-break:break-word]","whitespace-pre-wrap",t&&!r&&"rounded-br-md",n&&!r&&"rounded-tr-md",!t&&!n&&!r&&"rounded-r-md"),children:e.content})]})}function Ob({messages:e}){return f.jsx("div",{...re("chat/user_msg_group/root"),className:q("group","flex flex-col gap-1 justify-end items-end"),children:e.map((t,n,r)=>f.jsx(Sb,{message:t,isFirstInGroup:n===0,isLastInGroup:n===r.length-1,isAloneInGroup:r.length===1},t.id))})}function Lb(e){const t=[];let n=null;return e.forEach(r=>{var i,a,s,u;(!n||((i=n[0])==null?void 0:i.type)!==r.type)&&(n=[],t.push(n)),((a=n[0])==null?void 0:a.type)==="FROM_AGENT"&&r.type==="FROM_AGENT"&&((s=r.agent)==null?void 0:s.id)!==((u=n[0].agent)==null?void 0:u.id)&&(n=[],t.push(n)),n.push(r)}),t}function Rb(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="FROM_USER"}function Db(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="FROM_BOT"}function vb(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="FROM_AGENT"}function Pb(){const{messagesState:{messages:e}}=W.useMessages(),{isAwaitingBotReply:t}=W.useIsAwaitingBotReply(),{componentStore:n}=W.useWidget(),r=W.useConfig(),{initialQuestions:i,initialQuestionsPosition:a}=r,s=X.useMemo(()=>Lb(e),[e]),u=r.persistentInitialMessages||[],l=!r.initialMessages||r.initialMessages.length===0?["Hello, how can I help you?"]:r.initialMessages,c=n.getComponent("loading"),d=X.useRef(null);function h(){setTimeout(()=>{const g=d.current;g&&(g.scrollTop=g.scrollHeight)},0)}return X.useEffect(()=>{h()},[e]),f.jsxs("div",{...re("chat/msgs/root"),ref:d,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[f.jsx("div",{...re("chat/persistent_initial_msgs/root"),children:u.map((g,p,E)=>f.jsx(Rn,{component:"bot_message",data:{message:g},id:g,type:"FROM_BOT",timestamp:Date.now().toString(),dataComponentNames:{messageContainer:"chat/persistent_initial_msg/root",message:"chat/persistent_initial_msg/msg"},classNames:{messageContainer:q("w-full flex flex-col items-center text-center"),message:"w-full bg-transparent border-none shadow-none text-xs"},isFirstInGroup:p===0,isLastInGroup:p===E.length-1,isAloneInGroup:E.length===1},`${g}-${p}`))}),e.length===0&&f.jsx(Da,{messages:l.map((g,p)=>({component:"bot_message",data:{message:g},id:`${g}-${p}`,type:"FROM_BOT",timestamp:Date.now().toString()})),suggestedReplies:a==="below-initial-messages"?i:void 0,agent:r.bot?{...r.bot,isAi:!0,id:null}:void 0}),s.map(g=>{var y,k,_;const p=(y=g==null?void 0:g[0])==null?void 0:y.type,E=(k=g[0])==null?void 0:k.id;if(!p||!E)return null;if(Rb(g))return f.jsx(Ob,{messages:g},E);if(Db(g)||vb(g)){const S=(_=g[0])==null?void 0:_.agent;return f.jsx(Da,{messages:g,agent:S},E)}return null}),t&&c&&f.jsx(c,{agent:r.bot})]})}function $o({className:e}){return f.jsx(le.LoaderIcon,{className:q("size-4 animate-spin",e)})}function si({width:e,height:t}){const{isSmallScreen:n}=Mt(),{contentIframeRef:r}=W.useWidget();X.useEffect(()=>{var i,a;e&&((i=r==null?void 0:r.current)==null||i.style.setProperty("--opencx-widget-width",e)),t&&((a=r==null?void 0:r.current)==null||a.style.setProperty("--opencx-widget-height",t))},[n,t,e,r])}function Mb(){const{messagesState:{isInitialFetchLoading:e}}=W.useMessages(),{sessionState:{session:t}}=W.useSessions(),{theme:n}=fn();si({width:n.screens.chat.width,height:n.screens.chat.height});const r=X.useRef((t==null?void 0:t.id)||"chat").current;return f.jsx("div",{...re("chat/root"),className:q("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:f.jsxs("div",{className:"size-full justify-between flex flex-col",children:[f.jsx(Ko,{}),f.jsx(be.AnimatePresence,{mode:"wait",children:e?f.jsx(ae,{className:"flex flex-col items-center justify-center w-full flex-1",children:f.jsx($o,{})},"loading"):f.jsxs(ae,{className:"flex flex-col w-full flex-1 overflow-auto",snapExit:!0,children:[f.jsx(Pb,{}),f.jsx(mb,{})]},r)})]})})}const An=ye.forwardRef(({className:e,type:t,...n},r)=>{const{isSmallScreen:i}=Mt(),a=ii();return f.jsx($e,{ref:r,children:f.jsx("input",{dir:a,type:t,className:q(i?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rtl:placeholder:text-right","bg-white","rounded-3xl px-4",e),...n})})});An.displayName="Input";function Bb({className:e}){return f.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:q("text-primary-foreground",e),children:f.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function Jo({className:e}){const{token:t}=W.useConfig();return f.jsx("div",{className:q("flex items-center justify-center gap-2 p-2 pt-0 bg-background",e),children:f.jsx($e,{children:f.jsxs("a",{href:`https://open.cx/?ref=${t}`,target:"_blank",rel:"noreferrer",className:q("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[f.jsx("span",{children:"Powered by"}),f.jsx("span",{children:" "}),f.jsxs("span",{className:"flex items-center gap-[1px]",children:[f.jsx("span",{children:f.jsx(Bb,{className:"size-3 inline-block"})}),f.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function Fb(){const{contentIframeRef:e}=W.useWidget(),t=X.useRef(null);return X.useEffect(()=>{const n=e==null?void 0:e.current;if(n&&t.current){const r=t.current;let i;const a=new ResizeObserver(()=>{i=requestAnimationFrame(()=>{const s=r.offsetHeight;n.style.setProperty("--opencx-widget-height",`${s.toFixed(1)}px`)})});return a.observe(r),()=>{cancelAnimationFrame(i),a.unobserve(r)}}},[e]),{observedElementRef:t}}const Hb=Gn.z.object({name:Gn.z.string().min(2),email:Gn.z.string().email()});function Ub(){var _,S,L,M,F,I,j,U,z;const{setIsOpen:e}=W.useWidgetTrigger(),{createUnverifiedContact:t}=W.useContact(),{isSmallScreen:n}=Mt(),r=W.useConfig(),{theme:i}=fn(),a=Bt(),{data:s}=W.usePreludeData(),{observedElementRef:u}=Fb();si({height:void 0,width:i.screens.welcome.width});const[l,c]=X.useState(((_=r.prefillUserData)==null?void 0:_.name)||""),[d,h]=X.useState(((S=r.prefillUserData)==null?void 0:S.email)||""),g=(r.extraDataCollectionFields||[]).filter(C=>C!=="name"&&C!=="email"&&!!C),[p,E]=X.useState({}),[y,k]=W._default(async C=>{C.preventDefault();const H=Hb.safeParse({name:l,email:d});H.success&&await t({email:H.data.email,non_verified_name:H.data.name},Object.values(p).filter(Boolean).length?p:void 0)},[l,d,p]);return f.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:i.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:f.jsxs("div",{ref:u,className:q("flex flex-col",n&&"h-full"),children:[f.jsxs("div",{dir:"auto",className:"flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10",children:[n&&f.jsx(ae,{className:"absolute top-6 right-6",children:f.jsx(Oe,{size:"selfless",onClick:()=>e(!1),children:f.jsx(le.XIcon,{className:"size-4"})})}),f.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(L=r.assets)!=null&&L.organizationLogo?f.jsx("img",{src:(M=r.assets)==null?void 0:M.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):f.jsx("h2",{className:"font-bold text-xl",dir:"auto",children:(F=s==null?void 0:s.data)==null?void 0:F.organizationName})}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("h1",{className:"text-2xl font-bold",dir:"auto",children:((j=(I=r.textContent)==null?void 0:I.welcomeScreen)==null?void 0:j.title)||a.get("welcome-title")}),f.jsx("p",{className:"/90 text-sm max-w-[320px] leading-relaxed",dir:"auto",children:((z=(U=r.textContent)==null?void 0:U.welcomeScreen)==null?void 0:z.description)||a.get("welcome-description")})]})]}),f.jsxs("div",{className:"z-10 px-2 pt-2 bp-0 bg-background space-y-2",dir:"auto",children:[f.jsxs("form",{onSubmit:k,className:"space-y-2",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(An,{value:l,onChange:C=>c(C.target.value),required:!0,placeholder:a.get("your-name"),name:"name"}),f.jsx(An,{required:!0,value:d,onChange:C=>h(C.target.value),type:"email",placeholder:a.get("your-email"),name:"email"}),g.map(C=>f.jsx(An,{value:p[C],onChange:H=>E(P=>({...P,[C]:H.target.value})),placeholder:`${C} (${a.get("optional")})`},C))]}),f.jsxs(Oe,{disabled:y.loading,className:"w-full rounded-3xl",size:"lg",children:[y.loading?a.get("starting-chat"):a.get("start-chat"),f.jsx(le.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),f.jsx(Jo,{})]})]})})}function zb({session:e}){const{bot:t}=W.useConfig(),{toChatScreen:n}=W.useWidgetRouter(),r=e.assignee.kind==="human"?e.assignee.name||"Support Agent":(t==null?void 0:t.name)||"AI Support Agent",i=e.assignee.kind==="human"?e.assignee.avatarUrl||"":(t==null?void 0:t.avatar)||"";return f.jsxs(Oe,{variant:"ghost",size:"lg",className:"rounded-full p-2 pr-4 flex text-start justify-between w-full whitespace-normal",onClick:()=>n(e.id),children:[f.jsxs("div",{className:"flex-1 flex gap-2 items-center",children:[f.jsx(be.AnimatePresence,{mode:"wait",children:f.jsx(ae,{snapExit:!0,children:f.jsxs(ti,{className:"size-10",children:[f.jsx(ni,{src:i,alt:"Agent Icon"}),f.jsx(ri,{children:f.jsx(le.UserRoundIcon,{className:"size-4"})})]})})}),f.jsxs("div",{className:"flex-1",children:[f.jsx(be.AnimatePresence,{mode:"wait",children:f.jsx(ae,{snapExit:!0,children:r},r)}),f.jsx(be.AnimatePresence,{mode:"wait",children:e.lastMessage?f.jsx(ae,{snapExit:!0,children:f.jsx(Ws,{remarkPlugins:[gs],rehypePlugins:[Oo],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):f.jsx(ae,{className:"w-1/2",snapExit:!0,children:f.jsx(Xo,{className:"h-4 w-full"})},"skeleton")})]})]}),f.jsx(le.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0"})]})}function jb(){const e=Bt(),{toChatScreen:t}=W.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:r}}=W.useSessions();return f.jsx("div",{className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:f.jsx(be.AnimatePresence,{mode:"wait",children:r?f.jsx(ae,{className:"flex-1 flex items-center justify-center",children:f.jsx($o,{})},"loading"):f.jsx(ae,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?f.jsxs(f.Fragment,{children:[f.jsx(be.AnimatePresence,{children:n.map((i,a)=>f.jsx(ae,{snapExit:!0,children:f.jsx(zb,{session:i})},`${i.id}-${a}`))}),f.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:X.createElement(Oe,{...re("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full rounded-3xl",onClick:()=>t()},e.get("new-conversation"))})]}):f.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[f.jsx("div",{className:"flex-1 flex items-center justify-center",children:f.jsx("p",{className:"text-muted-foreground",children:e.get("no-conversations-yet")})}),X.createElement(Oe,{...re("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full rounded-3xl",onClick:()=>t()},e.get("new-conversation"))]})},"sessions")})})}function Yb(){const{theme:e}=fn();return si({width:e.screens.sessions.width,height:e.screens.sessions.height}),f.jsxs("div",{...re("sessions/root"),className:q("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[f.jsxs("div",{className:"size-full flex flex-col",children:[f.jsx(Ko,{}),f.jsx(jb,{})]}),f.jsx(Jo,{})]})}function Wb(){W.usePreludeData();const{routerState:{screen:e}}=W.useWidgetRouter();return f.jsxs("div",{className:"relative bg-background size-full",children:[f.jsx(Vn.Container,{}),f.jsx(be.AnimatePresence,{mode:"wait",children:(()=>{switch(e){case"welcome":return f.jsx(ae,{fadeIn:"right",className:"size-full",snapExit:!0,children:f.jsx(Ub,{})},e);case"sessions":return f.jsx(ae,{fadeIn:"right",className:"size-full",snapExit:!0,children:f.jsx(Yb,{})},e);case"chat":return f.jsx(ae,{fadeIn:"right",className:"size-full",snapExit:!0,children:f.jsx(Mb,{})},e);default:return null}})()})]})}const qb=`<!DOCTYPE html>
46
46
  <html>
47
47
  <head>
48
48
  <style>