"use strict";var Pl=require("./style.css");Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Z=require("react");function nc(k){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(k){for(const C in k)if(C!=="default"){const Y=Object.getOwnPropertyDescriptor(k,C);Object.defineProperty(f,C,Y.get?Y:{enumerable:!0,get:()=>k[C]})}}return f.default=k,Object.freeze(f)}const Re=nc(Z);var ka={exports:{}},wi={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var pa;function tc(){if(pa)return wi;pa=1;var k=Z,f=Symbol.for("react.element"),C=Symbol.for("react.fragment"),Y=Object.prototype.hasOwnProperty,c=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,w={key:!0,ref:!0,__self:!0,__source:!0};function O(y,d,v){var L,F={},ee=null,he=null;v!==void 0&&(ee=""+v),d.key!==void 0&&(ee=""+d.key),d.ref!==void 0&&(he=d.ref);for(L in d)Y.call(d,L)&&!w.hasOwnProperty(L)&&(F[L]=d[L]);if(y&&y.defaultProps)for(L in d=y.defaultProps,d)F[L]===void 0&&(F[L]=d[L]);return{$$typeof:f,type:y,key:ee,ref:he,props:F,_owner:c.current}}return wi.Fragment=C,wi.jsx=O,wi.jsxs=O,wi}var pi={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ja;function rc(){return Ja||(Ja=1,process.env.NODE_ENV!=="production"&&function(){var k=Z,f=Symbol.for("react.element"),C=Symbol.for("react.portal"),Y=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),y=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),he=Symbol.for("react.offscreen"),se=Symbol.iterator,ue="@@iterator";function X(R){if(R===null||typeof R!="object")return null;var b=se&&R[se]||R[ue];return typeof b=="function"?b:null}var P=k.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function q(R){{for(var b=arguments.length,j=new Array(b>1?b-1:0),W=1;W=1&&Ce>=0&&re[Ie]!==ke[Ce];)Ce--;for(;Ie>=1&&Ce>=0;Ie--,Ce--)if(re[Ie]!==ke[Ce]){if(Ie!==1||Ce!==1)do if(Ie--,Ce--,Ce<0||re[Ie]!==ke[Ce]){var ve=` `+re[Ie].replace(" at new "," at ");return R.displayName&&ve.includes("")&&(ve=ve.replace("",R.displayName)),typeof R=="function"&&kA.set(R,ve),ve}while(Ie>=1&&Ce>=0);break}}}finally{nA=!1,Ze.current=te,eA(),Error.prepareStackTrace=ne}var iA=R?R.displayName||R.name:"",cA=iA?jA(iA):"";return typeof R=="function"&&kA.set(R,cA),cA}function rA(R,b,j){return VA(R,!1)}function IA(R){var b=R.prototype;return!!(b&&b.isReactComponent)}function TA(R,b,j){if(R==null)return"";if(typeof R=="function")return VA(R,IA(R));if(typeof R=="string")return jA(R);switch(R){case v:return jA("Suspense");case L:return jA("SuspenseList")}if(typeof R=="object")switch(R.$$typeof){case d:return rA(R.render);case F:return TA(R.type,b,j);case ee:{var W=R,ne=W._payload,te=W._init;try{return TA(te(ne),b,j)}catch{}}}return""}var GA=Object.prototype.hasOwnProperty,Mn={},dA=P.ReactDebugCurrentFrame;function mA(R){if(R){var b=R._owner,j=TA(R.type,R._source,b?b.type:null);dA.setExtraStackFrame(j)}else dA.setExtraStackFrame(null)}function XA(R,b,j,W,ne){{var te=Function.call.bind(GA);for(var ie in R)if(te(R,ie)){var re=void 0;try{if(typeof R[ie]!="function"){var ke=Error((W||"React class")+": "+j+" type `"+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof R[ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ke.name="Invariant Violation",ke}re=R[ie](b,ie,W,j,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ie){re=Ie}re&&!(re instanceof Error)&&(mA(ne),q("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",W||"React class",j,ie,typeof re),mA(null)),re instanceof Error&&!(re.message in Mn)&&(Mn[re.message]=!0,mA(ne),q("Failed %s type: %s",j,re.message),mA(null))}}}var pn=Array.isArray;function Xe(R){return pn(R)}function AA(R){{var b=typeof Symbol=="function"&&Symbol.toStringTag,j=b&&R[Symbol.toStringTag]||R.constructor.name||"Object";return j}}function oA(R){try{return hA(R),!1}catch{return!0}}function hA(R){return""+R}function PA(R){if(oA(R))return q("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",AA(R)),hA(R)}var xA=P.ReactCurrentOwner,He={key:!0,ref:!0,__self:!0,__source:!0},qA,NA,cn;cn={};function dn(R){if(GA.call(R,"ref")){var b=Object.getOwnPropertyDescriptor(R,"ref").get;if(b&&b.isReactWarning)return!1}return R.ref!==void 0}function _A(R){if(GA.call(R,"key")){var b=Object.getOwnPropertyDescriptor(R,"key").get;if(b&&b.isReactWarning)return!1}return R.key!==void 0}function Jn(R,b){if(typeof R.ref=="string"&&xA.current&&b&&xA.current.stateNode!==b){var j=de(xA.current.type);cn[j]||(q('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',de(xA.current.type),R.ref),cn[j]=!0)}}function vA(R,b){{var j=function(){qA||(qA=!0,q("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};j.isReactWarning=!0,Object.defineProperty(R,"key",{get:j,configurable:!0})}}function HA(R,b){{var j=function(){NA||(NA=!0,q("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",b))};j.isReactWarning=!0,Object.defineProperty(R,"ref",{get:j,configurable:!0})}}var xn=function(R,b,j,W,ne,te,ie){var re={$$typeof:f,type:R,key:b,ref:j,props:ie,_owner:te};return re._store={},Object.defineProperty(re._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(re,"_self",{configurable:!1,enumerable:!1,writable:!1,value:W}),Object.defineProperty(re,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ne}),Object.freeze&&(Object.freeze(re.props),Object.freeze(re)),re};function Un(R,b,j,W,ne){{var te,ie={},re=null,ke=null;j!==void 0&&(PA(j),re=""+j),_A(b)&&(PA(b.key),re=""+b.key),dn(b)&&(ke=b.ref,Jn(b,ne));for(te in b)GA.call(b,te)&&!He.hasOwnProperty(te)&&(ie[te]=b[te]);if(R&&R.defaultProps){var Ie=R.defaultProps;for(te in Ie)ie[te]===void 0&&(ie[te]=Ie[te])}if(re||ke){var Ce=typeof R=="function"?R.displayName||R.name||"Unknown":R;re&&vA(ie,Ce),ke&&HA(ie,Ce)}return xn(R,re,ke,ne,W,xA.current,ie)}}var gA=P.ReactCurrentOwner,wA=P.ReactDebugCurrentFrame;function uA(R){if(R){var b=R._owner,j=TA(R.type,R._source,b?b.type:null);wA.setExtraStackFrame(j)}else wA.setExtraStackFrame(null)}var Ge;Ge=!1;function pA(R){return typeof R=="object"&&R!==null&&R.$$typeof===f}function WA(){{if(gA.current){var R=de(gA.current.type);if(R)return` Check the render method of \``+R+"`."}return""}}function bA(R){{if(R!==void 0){var b=R.fileName.replace(/^.*[\\\/]/,""),j=R.lineNumber;return` Check your code at `+b+":"+j+"."}return""}}var RA={};function $A(R){{var b=WA();if(!b){var j=typeof R=="string"?R:R.displayName||R.name;j&&(b=` Check the top-level render call using <`+j+">.")}return b}}function JA(R,b){{if(!R._store||R._store.validated||R.key!=null)return;R._store.validated=!0;var j=$A(b);if(RA[j])return;RA[j]=!0;var W="";R&&R._owner&&R._owner!==gA.current&&(W=" It was passed a child from "+de(R._owner.type)+"."),uA(R),q('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',j,W),uA(null)}}function Le(R,b){{if(typeof R!="object")return;if(Xe(R))for(var j=0;j",re=" Did you accidentally export a JSX literal instead of a component?"):Ie=typeof R,q("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ie,re)}var Ce=Un(R,b,j,ne,te);if(Ce==null)return Ce;if(ie){var ve=b.children;if(ve!==void 0)if(W)if(Xe(ve)){for(var iA=0;iAnull}),CA=()=>Z.useContext(da),xa=Z.createContext({styles:{},setStyles:()=>null}),MA=()=>Z.useContext(xa);const oc=({buttons:k})=>{var c,w,O;const{settings:f}=CA(),{styles:C}=MA(),Y={...C.headerStyle};return N.jsxs("div",{style:Y,className:"rcb-chat-header-container",children:[N.jsxs("div",{className:"rcb-chat-header",children:[((c=f.header)==null?void 0:c.showAvatar)&&N.jsx("div",{style:{backgroundImage:`url(${(w=f.header)==null?void 0:w.avatar})`},className:"rcb-bot-avatar"}),N.jsx("div",{style:{margin:0,fontSize:20,fontWeight:"bold"},children:(O=f.header)==null?void 0:O.title})]}),N.jsx("div",{className:"rcb-chat-header",children:k==null?void 0:k.map((y,d)=>N.jsx(Z.Fragment,{children:y},d))})]})};const ic=({chatBodyRef:k,isScrolling:f,setIsScrolling:C,unreadCount:Y})=>{var se,ue,X;const{settings:c}=CA(),{styles:w}=MA(),[O,y]=Z.useState(!1),d={color:(se=c.general)==null?void 0:se.primaryColor,borderColor:(ue=c.general)==null?void 0:ue.primaryColor,...w.chatMessagePromptHoveredStyle},v=()=>{y(!0)},L=()=>{y(!1)};function F(P){if(!k.current)return;const q=k.current.scrollTop,oe=k.current.scrollHeight-k.current.clientHeight-q,ae=20;let Ae=0;function le(){if(!k.current)return;Ae+=ae;const Je=ee(Ae,q,oe,P);k.current.scrollTop=Je,Ae(P/=oe/2,P<1?fe/2*P*P+q:(P--,-fe/2*(P*(P-2)-1)+q)),he=()=>{var q;return k.current&&((q=c.chatWindow)==null?void 0:q.showMessagePrompt)&&f&&Y>0?"visible":"hidden"};return N.jsx("div",{className:`rcb-message-prompt-container ${he()}`,children:N.jsx("div",{onMouseEnter:v,onMouseLeave:L,style:O?d:w.chatMessagePromptStyle,onMouseDown:P=>{P.preventDefault(),F(600)},className:"rcb-message-prompt-text",children:(X=c.chatWindow)==null?void 0:X.messagePromptText})})},Ra=Z.createContext({messages:[],setMessages:()=>null}),Oa=()=>Z.useContext(Ra);const sc=({chatBodyRef:k,isBotTyping:f,isLoadingChatHistory:C,chatScrollHeight:Y,setChatScrollHeight:c,setIsLoadingChatHistory:w,isScrolling:O,setIsScrolling:y,unreadCount:d,setUnreadCount:v})=>{var Ae,le,Je,Me,Ne,De,Ue,de,me,be;const{settings:L}=CA(),{styles:F}=MA(),{messages:ee}=Oa(),he={...F==null?void 0:F.bodyStyle,scrollbarWidth:(Ae=L.chatWindow)!=null&&Ae.showScrollbar?"auto":"none"},se={backgroundColor:(le=L.general)==null?void 0:le.primaryColor,color:"#fff",maxWidth:(Je=L.userBubble)!=null&&Je.showAvatar?"65%":"70%",...F.userBubbleStyle},ue=(Me=L.userBubble)!=null&&Me.animate?"rcb-user-message-entry":"",X={backgroundColor:(Ne=L.general)==null?void 0:Ne.secondaryColor,color:"#fff",maxWidth:(De=L.botBubble)!=null&&De.showAvatar?"65%":"70%",...F.botBubbleStyle},P=(Ue=L.botBubble)!=null&&Ue.animate?"rcb-bot-message-entry":"";Z.useEffect(()=>{var Ye;if(k.current){if(C){const{scrollHeight:je}=k.current,pe=je-Y;k.current.scrollTop=k.current.scrollTop+pe,w(!1);return}((Ye=L.chatWindow)!=null&&Ye.autoJumpToBottom||!O)&&(k.current.scrollTop=k.current.scrollHeight,L.isOpen&&v(0))}},[ee.length,f]),Z.useEffect(()=>{k.current&&(c(k.current.scrollHeight),O||(k.current.scrollTop=k.current.scrollHeight,L.isOpen&&v(0)))},[(de=k.current)==null?void 0:de.scrollHeight]),Z.useEffect(()=>{O||v(0)},[O]);const q=()=>{var Ke;if(!k.current)return;const{scrollTop:Ye,clientHeight:je,scrollHeight:pe}=k.current;y(Ye+je=pe-1&&(k.current.scrollTop=pe-je-1)},fe=Ye=>Ye===0?!0:ee[Ye].sender!==ee[Ye-1].sender,oe=(Ye,je)=>{var Pe,ye,aA,BA;const pe=fe(je),Ke=((Pe=L.userBubble)==null?void 0:Pe.showAvatar)&&pe;let $e="rcb-user-message";return!pe&&((ye=L.userBubble)!=null&&ye.showAvatar)&&($e+=" rcb-user-message-offset"),N.jsxs("div",{className:"rcb-user-message-container",children:[typeof Ye.content=="string"?(aA=L==null?void 0:L.userBubble)!=null&&aA.dangerouslySetInnerHtml?N.jsx("div",{style:{...se,display:"inline"},className:`${$e} ${ue}`,dangerouslySetInnerHTML:{__html:Ye.content}}):N.jsx("div",{style:se,className:`${$e} ${ue}`,children:Ye.content}):Ye.content,Ke&&N.jsx("div",{style:{backgroundImage:`url(${(BA=L.userBubble)==null?void 0:BA.avatar})`},className:"rcb-message-user-avatar"})]})},ae=(Ye,je)=>{var Pe,ye,aA,BA;const pe=fe(je),Ke=((Pe=L.botBubble)==null?void 0:Pe.showAvatar)&&pe;let $e="rcb-bot-message";return!pe&&((ye=L.botBubble)!=null&&ye.showAvatar)&&($e+=" rcb-bot-message-offset"),N.jsxs("div",{className:"rcb-bot-message-container",children:[Ke&&N.jsx("div",{style:{backgroundImage:`url(${(aA=L.botBubble)==null?void 0:aA.avatar})`},className:"rcb-message-bot-avatar"}),typeof Ye.content=="string"?(BA=L==null?void 0:L.botBubble)!=null&&BA.dangerouslySetInnerHtml?N.jsx("div",{style:{...X,display:"inline"},className:`${$e} ${P}`,dangerouslySetInnerHTML:{__html:Ye.content}}):N.jsx("div",{style:X,className:`${$e} ${P}`,children:Ye.content}):Ye.content]})};return N.jsxs("div",{style:he,className:"rcb-chat-body-container",ref:k,onScroll:q,children:[ee.map((Ye,je)=>Ye.sender==="system"?N.jsx("div",{children:Ye.content},je):N.jsx("div",{children:Ye.sender==="user"?oe(Ye,je):ae(Ye,je)},je)),f&&N.jsxs("div",{className:"rcb-bot-message-container",children:[((me=L.botBubble)==null?void 0:me.showAvatar)&&N.jsx("div",{style:{backgroundImage:`url(${(be=L.botBubble)==null?void 0:be.avatar})`},className:"rcb-message-bot-avatar"}),N.jsx("div",{onMouseDown:Ye=>{Ye.preventDefault()},className:`rcb-bot-message ${P}`,children:N.jsxs("div",{className:"rcb-typing-indicator",children:[N.jsx("span",{className:"rcb-dot"}),N.jsx("span",{className:"rcb-dot"}),N.jsx("span",{className:"rcb-dot"})]})})]}),N.jsx(ic,{chatBodyRef:k,isScrolling:O,setIsScrolling:y,unreadCount:d})]})},qn=!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),Ua=k=>{if(!k)return!1;const f=k.getBoundingClientRect(),C=window.innerHeight||document.documentElement.clientHeight,Y=window.innerWidth||document.documentElement.clientWidth;return f.top>=0&&f.left>=0&&f.bottom<=C&&f.right<=Y};const ac=({inputRef:k,textAreaDisabled:f,textAreaSensitiveMode:C,inputLength:Y,setInputLength:c,handleSubmit:w,hasFlowStarted:O,setHasFlowStarted:y,buttons:d})=>{var le,Je,Me,Ne,De,Ue,de,me,be,Ye;const{settings:v}=CA(),{styles:L}=MA(),[F,ee]=Z.useState(!1),he={boxSizing:qn?"content-box":"border-box",...L.chatInputAreaStyle},se={outline:f?"":"none",boxShadow:f?"":`0 0 5px ${(le=v.general)==null?void 0:le.primaryColor}`,boxSizing:qn?"content-box":"border-box",...L.chatInputAreaStyle,...L.chatInputAreaFocusedStyle},ue={cursor:`url(${(Je=v.general)==null?void 0:Je.actionDisabledIcon}), auto`,caretColor:"transparent",boxSizing:qn?"content-box":"border-box",...L.chatInputAreaStyle,...L.chatInputAreaDisabledStyle},X={color:"#989898",...L.characterLimitStyle},P={color:"#ff0000",...L.characterLimitReachedStyle},q=f?(Me=v.chatInput)==null?void 0:Me.disabledPlaceholderText:(Ne=v.chatInput)==null?void 0:Ne.enabledPlaceholderText,fe=()=>{f||ee(!0)},oe=()=>{ee(!1)},ae=je=>{var pe;if(je.key==="Enter"){if(je.shiftKey){(pe=v.chatInput)!=null&&pe.allowNewline||je.preventDefault();return}je.preventDefault(),w()}},Ae=je=>{var pe,Ke;if(f&&k.current){k.current.value="";return}if(k.current){const $e=(pe=v.chatInput)==null?void 0:pe.characterLimit,ye=((Ke=v.chatInput)==null?void 0:Ke.allowNewline)?je.target.value:je.target.value.replace(/\n/g," ");$e!=null&&$e>=0&&ye.length>$e?k.current.value=ye.slice(0,$e):k.current.value=ye,c(k.current.value.length)}};return N.jsxs("div",{onMouseDown:je=>{var pe;je.stopPropagation(),!O&&((pe=v.general)==null?void 0:pe.flowStartTrigger)==="ON_CHATBOT_INTERACT"&&y(!0)},style:L.chatInputContainerStyle,className:"rcb-chat-input",children:[C&&((De=v.sensitiveInput)!=null&&De.maskInTextArea)?N.jsx("input",{ref:k,type:"password",className:"rcb-chat-input-textarea",style:f?ue:F?se:he,placeholder:q,onChange:Ae,onKeyDown:ae,onFocus:fe,onBlur:oe}):N.jsx("textarea",{ref:k,style:f?ue:F?se:he,rows:1,className:"rcb-chat-input-textarea",placeholder:q,onChange:Ae,onKeyDown:ae,onFocus:fe,onBlur:oe}),N.jsxs("div",{className:"rcb-chat-input-button-container",children:[d==null?void 0:d.map((je,pe)=>N.jsx(Z.Fragment,{children:je},pe)),((Ue=v.chatInput)==null?void 0:Ue.showCharacterCount)&&((de=v.chatInput)==null?void 0:de.characterLimit)!=null&&((me=v.chatInput)==null?void 0:me.characterLimit)>0&&N.jsxs("div",{className:"rcb-chat-input-char-counter",style:Y>=((be=v.chatInput)==null?void 0:be.characterLimit)?P:X,children:[Y,"/",(Ye=v.chatInput)==null?void 0:Ye.characterLimit]})]})]})};const cc=({buttons:k})=>{var Y;const{settings:f}=CA(),{styles:C}=MA();return N.jsxs("div",{style:C.footerStyle,className:"rcb-chat-footer-container",children:[N.jsx("div",{className:"rcb-chat-footer",children:k==null?void 0:k.map((c,w)=>N.jsx(Z.Fragment,{children:c},w))}),N.jsx("span",{children:(Y=f.footer)==null?void 0:Y.text})]})};const lc=({unreadCount:k})=>{var y,d,v,L,F,ee;const{settings:f,setSettings:C}=CA(),{styles:Y}=MA(),c=()=>{C({...f,isOpen:!f.isOpen})},w={backgroundImage:`linear-gradient(to right, ${(y=f.general)==null?void 0:y.secondaryColor}, ${(d=f.general)==null?void 0:d.primaryColor})`,...Y.chatButtonStyle},O={backgroundImage:`url(${(v=f.chatButton)==null?void 0:v.icon})`,...Y.chatIconStyle};return N.jsx(N.Fragment,{children:!((L=f.general)!=null&&L.embedded)&&N.jsxs("button",{"aria-label":"Open Chat",style:w,className:`rcb-toggle-button ${f.isOpen?"rcb-button-hide":"rcb-button-show"}`,onClick:c,children:[N.jsx("span",{className:"rcb-toggle-icon",style:O}),!((F=f.notification)!=null&&F.disabled)&&((ee=f.notification)==null?void 0:ee.showCount)&&N.jsx("span",{style:Y.notificationBadgeStyle,className:"rcb-badge",children:k})]})})};const Ec=()=>{var F,ee,he,se,ue;const{settings:k,setSettings:f}=CA(),{styles:C}=MA(),[Y,c]=Z.useState(!1),[w,O]=Z.useState(!1),[y,d]=Z.useState(0);Z.useEffect(()=>{var P,q,fe;const X=(P=k.tooltip)==null?void 0:P.mode;if(X==="ALWAYS")if(qn){let oe;k.isOpen?oe=(((q=C.chatWindowStyle)==null?void 0:q.width)||375)-(((fe=C.chatButtonStyle)==null?void 0:fe.width)||75):oe=0,d(oe),c(!0)}else k.isOpen?c(!1):c(!0);else X==="NEVER"?c(!1):X==="START"?w?c(!1):(O(!0),c(!0)):X==="CLOSE"&&c(!k.isOpen)},[k.isOpen]);const v={transform:`translateX(-${y}px)`,right:(((F=C.chatButtonStyle)==null?void 0:F.width)||75)+40,bottom:30,backgroundColor:(ee=k.general)==null?void 0:ee.secondaryColor,color:(he=k.general)==null?void 0:he.secondaryColor,...C.tooltipStyle},L={borderColor:`transparent transparent transparent ${v.backgroundColor}`};return N.jsx(N.Fragment,{children:!((se=k.general)!=null&&se.embedded)&&N.jsxs("div",{style:v,className:`rcb-chat-tooltip ${Y?"rcb-tooltip-show":"rcb-tooltip-hide"}`,onClick:()=>f({...k,isOpen:!0}),children:[N.jsx("span",{style:{color:"#fff"},children:(ue=k.tooltip)==null?void 0:ue.text}),N.jsx("span",{className:"rcb-chat-tooltip-tail",style:L})]})})};const gc=({chatHistory:k,showChatHistory:f})=>{var v,L,F;const{settings:C}=CA(),{styles:Y}=MA(),[c,w]=Z.useState(!1),O={color:(v=C.general)==null?void 0:v.primaryColor,borderColor:(L=C.general)==null?void 0:L.primaryColor,...Y.chatHistoryButtonHoveredStyle},y=()=>{w(!0)},d=()=>{w(!1)};return N.jsx("div",{className:"rcb-view-history-container",children:N.jsx("div",{onMouseEnter:y,onMouseLeave:d,style:c?O:Y.chatHistoryButtonStyle,onMouseDown:ee=>{ee.preventDefault(),f(k)},className:"rcb-view-history-button",children:N.jsx("p",{children:(F=C.chatHistory)==null?void 0:F.viewChatHistoryButtonText})})})},Ya=Z.createContext({paths:[],setPaths:()=>null}),va=()=>Z.useContext(Ya);const fc=({checkboxes:k,checkedItems:f,path:C,handleActionInput:Y})=>{var X,P,q,fe,oe,ae,Ae,le,Je,Me,Ne;const{settings:c}=CA(),{styles:w}=MA(),{paths:O}=va(),[y,d]=Z.useState(new Set),[v,L]=Z.useState(!1),F={cursor:v?`url(${(X=c.general)==null?void 0:X.actionDisabledIcon}), auto`:"pointer",color:(P=c.general)==null?void 0:P.primaryColor,borderColor:(q=c.general)==null?void 0:q.primaryColor,...w.botCheckboxRowStyle},ee={cursor:v||y.size{O.length>0&&O[O.length-1]!==C&&L(!0)},[O]);const ue=De=>{v||d(Ue=>{const de=new Set(Ue);if(de.has(De))f.delete(De),de.delete(De);else{if(y.size==k.max)return Ue;f.add(De),de.add(De)}return de})};return N.jsxs("div",{className:`rcb-checkbox-container ${(Ne=c.botBubble)!=null&&Ne.showAvatar?"rcb-checkbox-offset":""}`,children:[k.items.map(De=>N.jsx("div",{onMouseDown:Ue=>{Ue.preventDefault(),ue(De)},style:F,className:"rcb-checkbox-row-container",children:N.jsxs("div",{className:"rcb-checkbox-row",children:[N.jsx("div",{style:y.has(De)?se:he,className:"rcb-checkbox-mark"}),N.jsx("div",{className:"rcb-checkbox-label",children:De})]})},De)),N.jsx("button",{style:ee,className:"rcb-checkbox-next-button",disabled:v||y.size{var de;De.preventDefault();const Ue=Array.from(f).join(", ");L(!0),Y(C,Ue,(de=c.chatInput)==null?void 0:de.sendCheckboxOutput)}})]})},Ic=async(k,f,C,Y)=>{const c=k.checkboxes;if(!c)return;let w;if(typeof c=="function"?(w=c(Y),w instanceof Promise&&(w=await w)):w=c,w.items.length==0)return;w.min==null&&(w.min=1),w.max==null&&(w.max=w.items.length),w.min>w.max&&(w.min=w.max);const O=new Set,y=N.jsx(fc,{checkboxes:w,checkedItems:O,path:f,handleActionInput:C});Y.injectMessage(y)},Bc=async(k,f)=>{const C=k.function;if(!C)return;const Y=C(f);return Y instanceof Promise?await Y:Y},hc=async(k,f)=>{const C=k.message;if(!C)return;if(typeof C=="string"){C.trim()!==""&&await f.injectMessage(C);return}let Y=C(f);Y instanceof Promise&&(Y=await Y),Y&&Y.trim()!==""&&await f.injectMessage(Y)};const uc=({options:k,path:f,handleActionInput:C})=>{var se,ue,X,P,q,fe;const{settings:Y}=CA(),{styles:c}=MA(),{paths:w}=va(),[O,y]=Z.useState([]),[d,v]=Z.useState(!1),L={cursor:d?`url(${(se=Y.general)==null?void 0:se.actionDisabledIcon}), auto`:"pointer",color:(ue=Y.general)==null?void 0:ue.primaryColor,borderColor:(X=Y.general)==null?void 0:X.primaryColor,backgroundColor:"#fff",...c.botOptionStyle},F={color:"#fff",borderColor:(P=Y.general)==null?void 0:P.primaryColor,backgroundColor:(q=Y.general)==null?void 0:q.primaryColor,...c.botOptionHoveredStyle};Z.useEffect(()=>{w.length>0&&w[w.length-1]!==f&&v(!0)},[w]);const ee=oe=>{y(ae=>{const Ae=[...ae];return Ae[oe]=!0,Ae})},he=oe=>{y(ae=>{const Ae=[...ae];return Ae[oe]=!1,Ae})};return N.jsx("div",{className:`rcb-options-container ${(fe=Y.botBubble)!=null&&fe.showAvatar?"rcb-options-offset":""}`,children:k.map((oe,ae)=>{const Ae=O[ae]&&!d;return N.jsx("div",{className:"rcb-options",style:Ae?F:L,onMouseEnter:()=>ee(ae),onMouseLeave:()=>he(ae),onMouseDown:le=>{var Je;le.preventDefault(),!d&&(v(!0),C(f,oe,(Je=Y.chatInput)==null?void 0:Je.sendOptionOutput))},children:oe},oe)})})},kc=async(k,f,C,Y)=>{const c=k.options;if(!c)return;let w;typeof c=="function"?(w=c(Y),w instanceof Promise&&(w=await w)):w=c;const O=N.jsx(uc,{options:w,path:f,handleActionInput:C});Y.injectMessage(O)},Sc=async(k,f,C)=>{const Y=k.path;if(!Y)return!1;if(typeof Y=="string")return C(O=>[...O,Y]),!0;let c=Y(f);if(c instanceof Promise&&(c=await c),!c)return!1;const w=c;return C(O=>[...O,w]),!0},Qc=async(k,f)=>{const C=k.component;if(C){if(typeof C=="function"){let Y=C(f);if(Y instanceof Promise&&(Y=await Y),!Y)return;await f.injectMessage(Y);return}await f.injectMessage(C)}},Cc=async(k,f,C,Y,c)=>{const w=k[f];if(!w)throw new Error("block is not valid.");const O=w.transition;let y;if(typeof O=="function"?(y=O(C),y instanceof Promise&&(y=await y)):y=O,!y||y instanceof Promise||y.duration==null||typeof y.duration!="number")return;y.interruptable||(y.interruptable=!1);const d=setTimeout(async()=>{await Sa(k,f,C,Y)},y.duration);y.interruptable&&c(d)},Mc=async(k,f,C)=>{const Y=k.chatDisabled;if(Y==null)return;let c;typeof Y=="function"?(c=Y(C),c instanceof Promise&&(c=await c)):c=Y,f(c)},Ka=async(k,f,C)=>{const Y=k.isSensitive;if(!Y){f(!1);return}let c;typeof Y=="function"?(c=Y(C),c instanceof Promise&&(c=await c)):c=Y,f(c)},dc=async(k,f,C,Y,c,w,O,y)=>{const d=k[f];if(!d)throw new Error("Block is not valid.");for(const v of Object.keys(d))switch(v){case"message":await hc(d,C);break;case"options":await kc(d,f,y,C);break;case"checkboxes":await Ic(d,f,y,C);break;case"component":await Qc(d,C);break;case"chatDisabled":await Mc(d,Y,C);break;case"isSensitive":await Ka(d,c,C);break;case"transition":await Cc(k,f,C,w,O)}},Sa=async(k,f,C,Y)=>{const c=k[f];if(!c)throw new Error("Block is not valid.");const w=Object.keys(c);for(const O of w)O==="function"&&await Bc(c,C);return w.includes("path")?await Sc(c,C,Y):!1};var yr={},pr={};/** * @license React * react-dom-server-legacy.browser.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ya;function xc(){if(ya)return pr;ya=1;var k=Z;function f(r){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+r,h=1;h