@robylon/whatsapp-react-sdk 1.0.1 → 1.0.2
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/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/robylon-chatbot.js +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";var e=require("react"),t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};var n,i,o,r,a,l,s,c=function(){return c=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},c.apply(this,arguments)};function d(e,t,n,i){return new(n||(n=Promise))(function(o,r){function a(e){try{s(i.next(e))}catch(e){r(e)}}function l(e){try{s(i.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,l)}s((i=i.apply(e,t||[])).next())})}function u(e,t){var n,i,o,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(s){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(r=0)),r;)try{if(n=1,i&&(o=2&l[0]?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){r=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){r.label=l[1];break}if(6===l[0]&&r.label<o[1]){r.label=o[1],o=l;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(l);break}o[2]&&r.ops.pop(),r.trys.pop();continue}l=t.call(e,r)}catch(e){l=[6,e],i=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}}function p(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,exports.ChatbotInterfaceType=void 0,(n=exports.ChatbotInterfaceType||(exports.ChatbotInterfaceType={})).WIDGET="WIDGET",n.POPOVER="POPOVER",n.EMBED="EMBED",exports.WidgetPositionEnums=void 0,(i=exports.WidgetPositionEnums||(exports.WidgetPositionEnums={})).RIGHT="Right",i.LEFT="Left",exports.LauncherType=void 0,(o=exports.LauncherType||(exports.LauncherType={})).TEXT="TEXT",o.IMAGE="IMAGE",o.TEXTUAL_IMAGE="TEXTUAL_IMAGE",exports.ProactiveSendTimeType=void 0,(r=exports.ProactiveSendTimeType||(exports.ProactiveSendTimeType={})).WORKING_HOURS="WORKING_HOURS",r.ALWAYS="ALWAYS",exports.DisplayAttributesType=void 0,(exports.DisplayAttributesType||(exports.DisplayAttributesType={})).URL="URL",exports.LogicalConditionType=void 0,(a=exports.LogicalConditionType||(exports.LogicalConditionType={})).AND="AND",a.OR="OR",exports.ConditionType=void 0,(l=exports.ConditionType||(exports.ConditionType={})).IS="IS",l.IS_NOT="IS_NOT",l.CONTAINS="CONTAINS",l.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",l.STARTS_WITH="STARTS_WITH",l.ENDS_WITH="ENDS_WITH",exports.MessageDisplayType=void 0,(s=exports.MessageDisplayType||(exports.MessageDisplayType={})).BUTTON="BUTTON",s.TEXT="TEXT";var f,m,h=function(e,t){void 0===t&&(t=.5);var n=function(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,t,n,i){return t+t+n+n+i+i});var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:0,g:0,b:0}}(e),i=function(e,t,n){var i=[e,t,n].map(function(e){return(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)});return.2126*i[0]+.7152*i[1]+.0722*i[2]}(n.r,n.g,n.b);return i>t?"#0E0E0F":"#FFFFFF"};!function(e){e.CHATBOT_BUTTON_LOADED="CHATBOT_BUTTON_LOADED",e.CHATBOT_BUTTON_CLICKED="CHATBOT_BUTTON_CLICKED",e.CHATBOT_OPENED="CHATBOT_OPENED",e.CHATBOT_CLOSED="CHATBOT_CLOSED",e.CHATBOT_APP_READY="CHATBOT_APP_READY",e.CHATBOT_LOADED="CHATBOT_LOADED",e.CHAT_INITIALIZED="CHAT_INITIALIZED",e.SESSION_REFRESHED="SESSION_REFRESHED",e.CHAT_INITIALIZATION_FAILED="CHAT_INITIALIZATION_FAILED",e.CHATBOT_READY="CHATBOT_READY"}(f||(f={})),function(e){e.CHAT_MOVED="CHAT_MOVED",e.CHATBOT_TOKEN_EXHAUSTED="CHATBOT_TOKEN_EXHAUSTED"}(m||(m={}));var g,v={log:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.log.apply(console,e)},error:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,e)},warn:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn.apply(console,e)},info:function(){}},y="system-ui, Inter, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",b='system-ui, Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif',_="21px",w="",x=[],E=!1,T=function(){return"undefined"==typeof window?"":window.location.href},I=function(){return T()},C=function(){var e=T();e!==w&&(w=e,x.forEach(function(t){return t(e)}))},S=function(e){return E||A(),x.push(e),e(T()),function(){var t=x.indexOf(e);t>-1&&x.splice(t,1)}},A=function(){if(!E&&"undefined"!=typeof window){E=!0,w=T();var e=function(e){var t=history[e];return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var i=t.apply(this,e);return setTimeout(C,0),i}};try{history.pushState=e("pushState"),history.replaceState=e("replaceState")}catch(e){}window.addEventListener("popstate",C),window.addEventListener("hashchange",C);var t=setInterval(function(){C()},1e3);setInterval(function(){0===x.length&&(clearInterval(t),window.removeEventListener("popstate",C),window.removeEventListener("hashchange",C),E=!1)},5e3)}},O=function(e,t,n,i){var o=t||"",r=T(),a=i||r,l=function(e,t){return-1!==t.indexOf(e)}(o,a);switch(n){case exports.ConditionType.IS:return a===o;case exports.ConditionType.IS_NOT:return a!==o;case exports.ConditionType.CONTAINS:return l;case exports.ConditionType.DOES_NOT_CONTAIN:return!l;case exports.ConditionType.STARTS_WITH:return a.startsWith(o);case exports.ConditionType.ENDS_WITH:return a.endsWith(o);default:return!1}},k=null,R=function(){k=I()},N=function(){return k===I()},D=function(e){c({input_id:null},e)},L=function(){return!0},M=((g={})[exports.ProactiveSendTimeType.WORKING_HOURS]=function(e,t){var n=t.getHours(),i=t.getMinutes();return(n>10||10===n&&i>=0)&&(n<19||19===n&&0===i)},g[exports.ProactiveSendTimeType.ALWAYS]=L,g),z=function(e){if(!e||N())return[];var t=T(),n=new Date,i=[];return e.forEach(function(e){i.push.apply(i,function(e,t,n){var i=(null==e?void 0:e.send_time_type)||"",o=i?M[i]:L;if(!o||!o(e,n))return[];for(var r=(null==e?void 0:e.content_multiple)||[],a=Math.max(0,1e3*Number((null==e?void 0:e.delay)||0)),l=[],s=0;s<r.length;s++){for(var c=r[s],d=(null==c?void 0:c.message_display_attributes)||[],u=null,p=exports.LogicalConditionType.OR,f=0,m=d;f<m.length;f++){var h=m[f];if(null==h?void 0:h.logical_condition)p=h.logical_condition;else{var g=h,v=O(null==g||g.type,(null==g?void 0:g.value)||"",null==g?void 0:g.condition,t);u=null===u?v:p===exports.LogicalConditionType.AND?u&&v:u||v}}(null===u||u)&&(null==c?void 0:c.message)&&l.push({messageId:(null==e?void 0:e.message_id)||String(s),contentIndex:s,html:String(c.message),delayMs:a,contentId:c.content_id||null,messageDisplayType:(null==c?void 0:c.message_display_type)||exports.MessageDisplayType.TEXT,messageBubbleBg:null==c?void 0:c.message_bubble_bg,urlToGo:null==c?void 0:c.url_to_go})}return l}(e,t,n))}),i};
|
|
2
2
|
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
|
|
3
|
-
const{entries:F,setPrototypeOf:B,isFrozen:H,getPrototypeOf:U,getOwnPropertyDescriptor:P}=Object;let{freeze:j,seal:W,create:G}=Object,{apply:X,construct:V}="undefined"!=typeof Reflect&&Reflect;j||(j=function(e){return e}),W||(W=function(e){return e}),X||(X=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),V||(V=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const Y=se(Array.prototype.forEach),K=se(Array.prototype.lastIndexOf),J=se(Array.prototype.pop),q=se(Array.prototype.push),Z=se(Array.prototype.splice),Q=se(String.prototype.toLowerCase),$=se(String.prototype.toString),ee=se(String.prototype.match),te=se(String.prototype.replace),ne=se(String.prototype.indexOf),ie=se(String.prototype.trim),oe=se(Object.prototype.hasOwnProperty),re=se(RegExp.prototype.test),ae=(le=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return V(le,t)});var le;function se(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return X(e,t,i)}}function ce(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Q;B&&B(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(H(t)||(t[i]=e),o=e)}e[o]=!0}return e}function de(e){for(let t=0;t<e.length;t++){oe(e,t)||(e[t]=null)}return e}function ue(e){const t=G(null);for(const[n,i]of F(e)){oe(e,n)&&(Array.isArray(i)?t[n]=de(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=ue(i):t[n]=i)}return t}function pe(e,t){for(;null!==e;){const n=P(e,t);if(n){if(n.get)return se(n.get);if("function"==typeof n.value)return se(n.value)}e=U(e)}return function(){return null}}const fe=j(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),me=j(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),he=j(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ge=j(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ve=j(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ye=j(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),be=j(["#text"]),_e=j(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),we=j(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xe=j(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ee=j(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Te=W(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ie=W(/<%[\w\W]*|[\w\W]*%>/gm),Ce=W(/\$\{[\w\W]*/gm),Se=W(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ae=W(/^aria-[\-\w]+$/),Oe=W(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ke=W(/^(?:\w+script|data):/i),Re=W(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ne=W(/^html$/i),De=W(/^[a-z][.\w]*(-[.\w]+)+$/i);var Le=Object.freeze({__proto__:null,ARIA_ATTR:Ae,ATTR_WHITESPACE:Re,CUSTOM_ELEMENT:De,DATA_ATTR:Se,DOCTYPE_NAME:Ne,ERB_EXPR:Ie,IS_ALLOWED_URI:Oe,IS_SCRIPT_OR_DATA:ke,MUSTACHE_EXPR:Te,TMPLIT_EXPR:Ce});const Me=1,ze=3,Fe=7,Be=8,He=9,Ue=function(){return"undefined"==typeof window?null:window};var Pe=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ue();const n=t=>e(t);if(n.version="3.3.3",n.removed=[],!t||!t.document||t.document.nodeType!==He||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,r=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:l,Node:s,Element:c,NodeFilter:d,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=t,h=c.prototype,g=pe(h,"cloneNode"),v=pe(h,"remove"),y=pe(h,"nextSibling"),b=pe(h,"childNodes"),_=pe(h,"parentNode");if("function"==typeof l){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let w,x="";const{implementation:E,createNodeIterator:T,createDocumentFragment:I,getElementsByTagName:C}=i,{importNode:S}=o;let A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof F&&"function"==typeof _&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:k,TMPLIT_EXPR:R,DATA_ATTR:N,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:z}=Le;let{IS_ALLOWED_URI:B}=Le,H=null;const U=ce({},[...fe,...me,...he,...ve,...be]);let P=null;const W=ce({},[..._e,...we,...xe,...Ee]);let X=Object.seal(G(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,le=null;const se=Object.seal(G(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let de=!0,Te=!0,Ie=!1,Ce=!0,Se=!1,Ae=!0,ke=!1,Re=!1,De=!1,Pe=!1,je=!1,We=!1,Ge=!0,Xe=!1,Ve=!0,Ye=!1,Ke={},Je=null;const qe=ce({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ze=null;const Qe=ce({},["audio","video","img","source","image","track"]);let $e=null;const et=ce({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",it="http://www.w3.org/1999/xhtml";let ot=it,rt=!1,at=null;const lt=ce({},[tt,nt,it],$);let st=ce({},["mi","mo","mn","ms","mtext"]),ct=ce({},["annotation-xml"]);const dt=ce({},["title","style","font","a","script"]);let ut=null;const pt=["application/xhtml+xml","text/html"];let ft=null,mt=null;const ht=i.createElement("form"),gt=function(e){return e instanceof RegExp||e instanceof Function},vt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!mt||mt!==e){if(e&&"object"==typeof e||(e={}),e=ue(e),ut=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ft="application/xhtml+xml"===ut?$:Q,H=oe(e,"ALLOWED_TAGS")?ce({},e.ALLOWED_TAGS,ft):U,P=oe(e,"ALLOWED_ATTR")?ce({},e.ALLOWED_ATTR,ft):W,at=oe(e,"ALLOWED_NAMESPACES")?ce({},e.ALLOWED_NAMESPACES,$):lt,$e=oe(e,"ADD_URI_SAFE_ATTR")?ce(ue(et),e.ADD_URI_SAFE_ATTR,ft):et,Ze=oe(e,"ADD_DATA_URI_TAGS")?ce(ue(Qe),e.ADD_DATA_URI_TAGS,ft):Qe,Je=oe(e,"FORBID_CONTENTS")?ce({},e.FORBID_CONTENTS,ft):qe,V=oe(e,"FORBID_TAGS")?ce({},e.FORBID_TAGS,ft):ue({}),le=oe(e,"FORBID_ATTR")?ce({},e.FORBID_ATTR,ft):ue({}),Ke=!!oe(e,"USE_PROFILES")&&e.USE_PROFILES,de=!1!==e.ALLOW_ARIA_ATTR,Te=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Se=e.SAFE_FOR_TEMPLATES||!1,Ae=!1!==e.SAFE_FOR_XML,ke=e.WHOLE_DOCUMENT||!1,Pe=e.RETURN_DOM||!1,je=e.RETURN_DOM_FRAGMENT||!1,We=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,Xe=e.SANITIZE_NAMED_PROPS||!1,Ve=!1!==e.KEEP_CONTENT,Ye=e.IN_PLACE||!1,B=e.ALLOWED_URI_REGEXP||Oe,ot=e.NAMESPACE||it,st=e.MATHML_TEXT_INTEGRATION_POINTS||st,ct=e.HTML_INTEGRATION_POINTS||ct,X=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(X.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Se&&(Te=!1),je&&(Pe=!0),Ke&&(H=ce({},be),P=G(null),!0===Ke.html&&(ce(H,fe),ce(P,_e)),!0===Ke.svg&&(ce(H,me),ce(P,we),ce(P,Ee)),!0===Ke.svgFilters&&(ce(H,he),ce(P,we),ce(P,Ee)),!0===Ke.mathMl&&(ce(H,ve),ce(P,xe),ce(P,Ee))),oe(e,"ADD_TAGS")||(se.tagCheck=null),oe(e,"ADD_ATTR")||(se.attributeCheck=null),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?se.tagCheck=e.ADD_TAGS:(H===U&&(H=ue(H)),ce(H,e.ADD_TAGS,ft))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?se.attributeCheck=e.ADD_ATTR:(P===W&&(P=ue(P)),ce(P,e.ADD_ATTR,ft))),e.ADD_URI_SAFE_ATTR&&ce($e,e.ADD_URI_SAFE_ATTR,ft),e.FORBID_CONTENTS&&(Je===qe&&(Je=ue(Je)),ce(Je,e.FORBID_CONTENTS,ft)),e.ADD_FORBID_CONTENTS&&(Je===qe&&(Je=ue(Je)),ce(Je,e.ADD_FORBID_CONTENTS,ft)),Ve&&(H["#text"]=!0),ke&&ce(H,["html","head","body"]),H.table&&(ce(H,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,x=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(m,r)),null!==w&&"string"==typeof x&&(x=w.createHTML(""));j&&j(e),mt=e}},yt=ce({},[...me,...he,...ge]),bt=ce({},[...ve,...ye]),_t=function(e){q(n.removed,{element:e});try{_(e).removeChild(e)}catch(t){v(e)}},wt=function(e,t){try{q(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){q(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Pe||je)try{_t(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},xt=function(e){let t=null,n=null;if(De)e="<remove></remove>"+e;else{const t=ee(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===it&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=w?w.createHTML(e):e;if(ot===it)try{t=(new f).parseFromString(o,ut)}catch(e){}if(!t||!t.documentElement){t=E.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?x:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),ot===it?C.call(t,ke?"html":"body")[0]:ke?t.documentElement:r},Et=function(e){return T.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Tt=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},It=function(e){return"function"==typeof s&&e instanceof s};function Ct(e,t,i){Y(e,e=>{e.call(n,t,i,mt)})}const St=function(e){let t=null;if(Ct(A.beforeSanitizeElements,e,null),Tt(e))return _t(e),!0;const i=ft(e.nodeName);if(Ct(A.uponSanitizeElement,e,{tagName:i,allowedTags:H}),Ae&&e.hasChildNodes()&&!It(e.firstElementChild)&&re(/<[/\w!]/g,e.innerHTML)&&re(/<[/\w!]/g,e.textContent))return _t(e),!0;if(e.nodeType===Fe)return _t(e),!0;if(Ae&&e.nodeType===Be&&re(/<[/\w]/g,e.data))return _t(e),!0;if(!(se.tagCheck instanceof Function&&se.tagCheck(i))&&(!H[i]||V[i])){if(!V[i]&&Ot(i)){if(X.tagNameCheck instanceof RegExp&&re(X.tagNameCheck,i))return!1;if(X.tagNameCheck instanceof Function&&X.tagNameCheck(i))return!1}if(Ve&&!Je[i]){const t=_(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=g(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,y(e))}}}return _t(e),!0}return e instanceof c&&!function(e){let t=_(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=Q(e.tagName),i=Q(t.tagName);return!!at[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===it?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===i||st[i]):Boolean(yt[n]):e.namespaceURI===tt?t.namespaceURI===it?"math"===n:t.namespaceURI===nt?"math"===n&&ct[i]:Boolean(bt[n]):e.namespaceURI===it?!(t.namespaceURI===nt&&!ct[i])&&!(t.namespaceURI===tt&&!st[i])&&!bt[n]&&(dt[n]||!yt[n]):!("application/xhtml+xml"!==ut||!at[e.namespaceURI]))}(e)?(_t(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!re(/<\/no(script|embed|frames)/i,e.innerHTML)?(Se&&e.nodeType===ze&&(t=e.textContent,Y([O,k,R],e=>{t=te(t,e," ")}),e.textContent!==t&&(q(n.removed,{element:e.cloneNode()}),e.textContent=t)),Ct(A.afterSanitizeElements,e,null),!1):(_t(e),!0)},At=function(e,t,n){if(le[t])return!1;if(Ge&&("id"===t||"name"===t)&&(n in i||n in ht))return!1;if(Te&&!le[t]&&re(N,t));else if(de&&re(D,t));else if(se.attributeCheck instanceof Function&&se.attributeCheck(t,e));else if(!P[t]||le[t]){if(!(Ot(e)&&(X.tagNameCheck instanceof RegExp&&re(X.tagNameCheck,e)||X.tagNameCheck instanceof Function&&X.tagNameCheck(e))&&(X.attributeNameCheck instanceof RegExp&&re(X.attributeNameCheck,t)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(t,e))||"is"===t&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&re(X.tagNameCheck,n)||X.tagNameCheck instanceof Function&&X.tagNameCheck(n))))return!1}else if($e[t]);else if(re(B,te(n,M,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==ne(n,"data:")||!Ze[e]){if(Ie&&!re(L,te(n,M,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&ee(e,z)},kt=function(e){Ct(A.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Tt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P,forceKeepAttr:void 0};let o=t.length;for(;o--;){const r=t[o],{name:a,namespaceURI:l,value:s}=r,c=ft(a),d=s;let u="value"===a?d:ie(d);if(i.attrName=c,i.attrValue=u,i.keepAttr=!0,i.forceKeepAttr=void 0,Ct(A.uponSanitizeAttribute,e,i),u=i.attrValue,!Xe||"id"!==c&&"name"!==c||(wt(a,e),u="user-content-"+u),Ae&&re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){wt(a,e);continue}if("attributename"===c&&ee(u,"href")){wt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){wt(a,e);continue}if(!Ce&&re(/\/>/i,u)){wt(a,e);continue}Se&&Y([O,k,R],e=>{u=te(u,e," ")});const p=ft(e.nodeName);if(At(p,c,u)){if(w&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(l);else switch(m.getAttributeType(p,c)){case"TrustedHTML":u=w.createHTML(u);break;case"TrustedScriptURL":u=w.createScriptURL(u)}if(u!==d)try{l?e.setAttributeNS(l,a,u):e.setAttribute(a,u),Tt(e)?_t(e):J(n.removed)}catch(t){wt(a,e)}}else wt(a,e)}Ct(A.afterSanitizeAttributes,e,null)},Rt=function e(t){let n=null;const i=Et(t);for(Ct(A.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)Ct(A.uponSanitizeShadowNode,n,null),St(n),kt(n),n.content instanceof a&&e(n.content);Ct(A.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,l=null,c=null;if(rt=!e,rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!It(e)){if("function"!=typeof e.toString)throw ae("toString is not a function");if("string"!=typeof(e=e.toString()))throw ae("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Re||vt(t),n.removed=[],"string"==typeof e&&(Ye=!1),Ye){if(e.nodeName){const t=ft(e.nodeName);if(!H[t]||V[t])throw ae("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)i=xt("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===Me&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!Pe&&!Se&&!ke&&-1===e.indexOf("<"))return w&&We?w.createHTML(e):e;if(i=xt(e),!i)return Pe?null:We?x:""}i&&De&&_t(i.firstChild);const d=Et(Ye?e:i);for(;l=d.nextNode();)St(l),kt(l),l.content instanceof a&&Rt(l.content);if(Ye)return e;if(Pe){if(je)for(c=I.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(P.shadowroot||P.shadowrootmode)&&(c=S.call(o,c,!0)),c}let u=ke?i.outerHTML:i.innerHTML;return ke&&H["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&re(Ne,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),Se&&Y([O,k,R],e=>{u=te(u,e," ")}),w&&We?w.createHTML(u):u},n.setConfig=function(){vt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Re=!0},n.clearConfig=function(){mt=null,Re=!1},n.isValidAttribute=function(e,t,n){mt||vt({});const i=ft(e),o=ft(t);return At(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&q(A[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=K(A[e],t);return-1===n?void 0:Z(A[e],n,1)[0]}return J(A[e])},n.removeHooks=function(e){A[e]=[]},n.removeAllHooks=function(){A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),je=function(e){return e?Pe.sanitize(e,{ALLOWED_TAGS:["b","strong","i","em","u","br","span","a","p","s"],ALLOWED_ATTR:["href","target","rel","style"],ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,RETURN_TRUSTED_TYPE:!1}):""};function We(e){if(!e||"string"!=typeof e||0===e.trim().length)return"ltr";var t=e.replace(/<[^>]*>/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`#]/g,"").trim();if(0===t.length)return"ltr";for(var n=/[\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,i=0,o=0,r=0,a=t;r<a.length;r++){var l=a[r];/\s|\d|[.,;:!?()[\]{}'"`\-_=+*/\\|@#$%^&*~]/.test(l)||(o++,n.test(l)&&i++)}return 0===o?"ltr":i/o>.3?"rtl":"ltr"}var Ge="https://cdn.robylon.ai/logos/WhatsApp.svg",Xe=e.memo(function(t){var n,i,o,r,a,l,s,d,u,m,g,b,w,x,E,T,I,C,A=t.config,O=t.toggleIframe,k=t.isIframeVisible,L=t.onEvent,M=t.onInternalEvent,F=t.position,B=t.sideSpacing,H=t.bottomSpacing,U=t.launcher_type,P=t.launcher_properties_text,j=t.shouldFadeIn,W=t.launcher_size,G=e.useRef(null),X=e.useState(!1),V=X[0],Y=X[1],K=e.useState(!1),J=K[0],q=K[1],Z=e.useState([]),Q=Z[0],$=Z[1],ee=e.useState(!1),te=ee[0],ne=ee[1],ie=e.useRef([]),oe=e.useRef(),re=e.useRef(new Set),ae=null!==(o=null==A?void 0:A.launcher_size_multiplier)&&void 0!==o?o:1,le=null!=W?W:48*ae,se="".concat(Math.max(4,Math.round(4*ae)),"px");e.useEffect(function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;Y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]),e.useEffect(function(){G.current&&requestAnimationFrame(function(){null==L||L({type:f.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),M(f.CHATBOT_BUTTON_LOADED)})},[L,M]),e.useEffect(function(){if(G.current&&j){G.current.style.opacity="0";var e=requestAnimationFrame(function(){G.current&&(G.current.style.opacity="1")});return function(){return cancelAnimationFrame(e)}}},[j]);var ce=F||(null===(r=A.interface_properties)||void 0===r?void 0:r.position)||"Right",de=null!==(l=null!=B?B:null===(a=A.interface_properties)||void 0===a?void 0:a.side_spacing)&&void 0!==l?l:20,ue=null!==(d=null!=H?H:null===(s=A.interface_properties)||void 0===s?void 0:s.bottom_spacing)&&void 0!==d?d:20,pe=U||(null==A?void 0:A.launcher_type)||exports.LauncherType.IMAGE,fe=P||(null===(u=null==A?void 0:A.launcher_properties)||void 0===u?void 0:u.text),me={zIndex:1e3,display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",boxSizing:"border-box"};pe===exports.LauncherType.IMAGE&&(me.width="".concat(le,"px"),me.height="".concat(le,"px"),me.borderRadius="50%",me.backgroundColor=A.brand_colour);var he=c(c({},me),((n={position:void 0,bottom:"0",borderRadius:pe===exports.LauncherType.IMAGE?"50%":"9999px"})[ce.toLowerCase()]="0",n)),ge=c(c({},me),((i={position:"fixed",bottom:"".concat(ue,"px"),borderRadius:pe===exports.LauncherType.IMAGE?"50%":"9999px"})[ce.toLowerCase()]="".concat(de,"px"),i)),ve=V?ge:he;e.useEffect(function(){v.log("Screen width changed, isMobile:",V,"Style:",ve)},[V,ve]),v.log("config in floating button",A);e.useEffect(function(){var e=function(){ie.current.forEach(function(e){return clearTimeout(e)}),ie.current=[]},t=function(){if(e(),$([]),re.current.clear(),(null==A?void 0:A.proactive_message_obj)&&!N()){var t=z(null==A?void 0:A.proactive_message_obj);p([],t,!0).sort(function(e,t){return e.delayMs!==t.delayMs?e.delayMs-t.delayMs:e.contentIndex-t.contentIndex});var n=new Map;t.forEach(function(e){var t=n.get(e.delayMs);t||(t={messageIds:[],groups:new Map},n.set(e.delayMs,t)),t.groups.has(e.messageId)||(t.messageIds.push(e.messageId),t.groups.set(e.messageId,[])),t.groups.get(e.messageId).push(e)}),n.forEach(function(e,t){var n=e.messageIds,i=e.groups,o=window.setTimeout(function(){$(function(e){var o=[];return n.forEach(function(t){(i.get(t)||[]).forEach(function(t){var n="".concat(t.messageId,"-").concat(t.contentIndex);if(!e.some(function(e){return e.id===t.messageId&&e.index===t.contentIndex})){var i={id:t.messageId,index:t.contentIndex,html:t.html,contentId:t.contentId,messageDisplayType:t.messageDisplayType,messageBubbleBg:null==t?void 0:t.messageBubbleBg,urlToGo:null==t?void 0:t.urlToGo};o.push(i),re.current.add(n),setTimeout(function(){re.current.delete(n)},1200)}})}),0===t?p(p([],e,!0),o,!0):p(p([],o,!0),e,!0)})},t);ie.current.push(o)})}};return oe.current=S(function(){q(!1),t()}),t(),function(){var t;e(),null===(t=oe.current)||void 0===t||t.call(oe)}},[null==A?void 0:A.proactive_message_obj]);var ye=Q.length>0&&!k&&!J,be="Right"===(F||(null===(m=A.interface_properties)||void 0===m?void 0:m.position)||"Right"),_e=function(){ne(!0),setTimeout(function(){q(!0),R(),ne(!1)},400)};return e.createElement(e.Fragment,null,e.createElement("style",null,"\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .proactive-bubble-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .proactive-bubble-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(y,';\n // font-size: inherit;\n // font-weight: inherit;\n line-height: inherit;\n color: inherit;\n text-align: inherit;\n // text-decoration: none ;\n list-style: none !important;\n }\n .proactive-message-content p,\n .proactive-message-content div,\n .proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .proactive-message-content p:first-child,\n .proactive-message-content div:first-child,\n .proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .proactive-message-content p:last-child,\n .proactive-message-content div:last-child,\n .proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .proactive-message-content b,\n .proactive-message-content strong {\n font-weight: 600 !important;\n }\n .proactive-message-content i,\n .proactive-message-content em {\n font-style: italic !important;\n }\n .proactive-message-content u {\n text-decoration: underline !important;\n }\n .proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n ')),ye?e.createElement("div",{className:"proactive-message-container",style:{position:"fixed",bottom:"".concat((null!==(b=null!=H?H:null===(g=A.interface_properties)||void 0===g?void 0:g.bottom_spacing)&&void 0!==b?b:20)+(pe===exports.LauncherType.IMAGE?le:void 0!==W?40:40*ae)+8,"px"),right:be?"".concat(null!==(x=null!=B?B:null===(w=A.interface_properties)||void 0===w?void 0:w.side_spacing)&&void 0!==x?x:20,"px"):"auto",left:be?"auto":"".concat(null!==(T=null!=B?B:null===(E=A.interface_properties)||void 0===E?void 0:E.side_spacing)&&void 0!==T?T:20,"px"),maxWidth:"22.875rem",zIndex:2147483646}},e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:be?"flex-end":"flex-start"},className:"proactive-message-bubble-container"},Q.map(function(t,n){var i="".concat(t.id,"-").concat(t.index),o=re.current.has(i),r=10*(Q.length-1-n),a=t.messageDisplayType===exports.MessageDisplayType.BUTTON;return console.log("visibleProactives",Q),e.createElement("div",{key:i,onClick:function(){if((null==t?void 0:t.urlToGo)&&"string"==typeof t.urlToGo&&""!==t.urlToGo.trim())window.open(t.urlToGo,"_blank","noopener,noreferrer");else{D({message_id:t.id,content_string:t.html||null,content_id:t.contentId||null}),O(),_e();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:t.id,content_string:t.html||null,content_id:t.contentId||null}}))}catch(e){}}},className:te?be?"proactive-bubble-exit-right":"proactive-bubble-exit-left":o&&!te?be?"proactive-bubble-enter-right":"proactive-bubble-enter-left":"",style:c({background:(null==t?void 0:t.messageBubbleBg)||"#ffffff",color:"#111",borderRadius:a?"100px":"12px",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.08)",padding:"16px",cursor:"pointer",fontFamily:y,lineHeight:_,fontSize:"14px",marginBottom:n<Q.length-1?16:0,border:"1px solid #F1F2F4",width:"fit-content",maxWidth:"100%",animationDelay:te?"0ms":o?"".concat(r,"ms"):void 0},te?{opacity:0}:o?{opacity:0,transform:be?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"}:{})},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},e.createElement("div",{className:"proactive-message-content",dir:We(t.html),dangerouslySetInnerHTML:{__html:je(t.html)}}),(null==t?void 0:t.urlToGo)&&"string"==typeof t.urlToGo&&""!==t.urlToGo.trim()&&e.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flexShrink:0,color:h((null==t?void 0:t.messageBubbleBg)||"#ffffff")}},e.createElement("g",{id:"External_Link"},e.createElement("path",{id:"Vector",d:"M6.6668 3.83268H5.4668C4.72006 3.83268 4.34642 3.83268 4.0612 3.97801C3.81032 4.10584 3.60649 4.30966 3.47866 4.56055C3.33334 4.84576 3.33334 5.21941 3.33334 5.96615V11.0328C3.33334 11.7795 3.33334 12.1527 3.47866 12.4379C3.60649 12.6888 3.81032 12.893 4.0612 13.0208C4.34614 13.166 4.71933 13.166 5.46461 13.166H10.5354C11.2807 13.166 11.6533 13.166 11.9383 13.0208C12.1891 12.893 12.3937 12.6886 12.5215 12.4377C12.6667 12.1528 12.6667 11.78 12.6667 11.0347V9.83268M13.3333 6.49935V3.16602M13.3333 3.16602H10M13.3333 3.16602L8.66667 7.83268",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})))))})),e.createElement("div",{onClick:function(e){e.stopPropagation(),_e()},className:te?"":be?"proactive-close-enter-right":"proactive-close-enter-left",style:c({position:"absolute",top:"-32px",right:"Right"===(F||(null===(I=A.interface_properties)||void 0===I?void 0:I.position)||"Right")?"0px":"auto",left:"Left"===(F||(null===(C=A.interface_properties)||void 0===C?void 0:C.position)||"Right")?"0px":"auto",width:"24px",height:"24px",borderRadius:"50%",background:"#fff",boxShadow:" 0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",userSelect:"none",animationDelay:te?"0ms":"".concat(10*(Q.length-1),"ms")},te?{}:{opacity:0,transform:be?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"}),"aria-label":"Close proactive message"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{d:"M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334",stroke:"#444547",strokeWidth:"0.816326",strokeLinecap:"round",strokeLinejoin:"round"})))):null,e.createElement("div",{ref:G,className:"message-bubble-container",style:c(c({},ve),{transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",transform:k?"scale(0.85)":"scale(1)",opacity:j?0:1}),onClick:function(){O(),_e()}},function(){switch(pe){case exports.LauncherType.TEXT:return t=void 0!==W?void 0:160*ae,n=void 0!==W?void 0:40*ae,i=void 0!==W?void 0:14*ae,o=void 0!==W?void 0:21*ae,e.createElement("div",{style:{width:void 0!==t?"".concat(t,"px"):"fit-content",maxWidth:void 0!==t?"".concat(t,"px"):"160px",height:void 0!==n?"".concat(n,"px"):"40px",borderRadius:"9999px",backgroundColor:A.brand_colour,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box",fontFamily:y,lineHeight:_}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:We(fe),style:{margin:0,color:h(A.brand_colour),fontSize:void 0!==i?"".concat(i,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:y,lineHeight:void 0!==o?"".concat(o,"px"):_,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},fe)));case exports.LauncherType.TEXTUAL_IMAGE:return function(){var t,n,i,o,r=void 0!==W?void 0:174*ae,a=void 0!==W?void 0:40*ae,l=void 0!==W?void 0:40*ae,s=void 0!==W?void 0:14*ae,c=void 0!==W?void 0:21*ae,d=(null==A?void 0:A.launcher_type)?(null===(i=null===(n=null===(t=null==A?void 0:A.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||void 0===i?void 0:i.trim())||Ge:(null===(o=null==A?void 0:A.image_url)||void 0===o?void 0:o.trim())||Ge,u=d===Ge;return e.createElement("div",{style:{maxWidth:void 0!==r?"".concat(r,"px"):"13rem",width:"fit-content",height:void 0!==a?"".concat(a,"px"):"40px",borderRadius:"9999px",backgroundColor:A.brand_colour,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:0,paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box",fontFamily:y,lineHeight:_}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:We(fe),style:{margin:0,color:h(A.brand_colour),fontSize:void 0!==s?"".concat(s,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:y,lineHeight:void 0!==c?"".concat(c,"px"):_,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},fe)),e.createElement("div",{style:{width:void 0!==l?"".concat(l,"px"):"40px",height:void 0!==l?"".concat(l,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:0}},e.createElement("img",{src:d,alt:"Chat",style:{width:u?"calc(100% - 6px)":"100%",height:u?"calc(100% - 6px)":"100%",margin:u?"3px":0,borderRadius:u?0:"50%",objectFit:u?"contain":"cover",padding:u?se:0,boxSizing:"border-box"}})))}();case exports.LauncherType.IMAGE:default:return function(){var t,n,i,o;if(k){var r=Math.round(.5*le);return e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"}},e.createElement("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"}},e.createElement("g",{id:"Chevron_Down"},e.createElement("path",{id:"Vector",d:"M19 9L12 16L5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))))}var a=(null==A?void 0:A.launcher_type)?(null===(i=null===(n=null===(t=null==A?void 0:A.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||void 0===i?void 0:i.trim())||Ge:(null===(o=null==A?void 0:A.image_url)||void 0===o?void 0:o.trim())||Ge,l=a===Ge;return e.createElement("img",{src:a,alt:"Chat",style:{zIndex:1e3,cursor:"pointer",borderRadius:l?0:"50%",objectFit:l?"contain":"cover",padding:l?se:0,width:l?"calc(100% - 3px)":"100%",height:l?"calc(100% - 3px)":"100%",margin:l?"4px":0,boxSizing:"border-box"}})}()}var t,n,i,o}()))}),Ve=function(t){var n=t.config,i=t.onCtaClick,o=(null==n?void 0:n.title_bar_color)||"#075E54",r=h(o),a=function(e){var t,n;if(null==e?void 0:e.startsWith("#")){var i=e.replace("#",""),o=3===(null==i?void 0:i.length)?null===(n=null===(t=null==i?void 0:i.split(""))||void 0===t?void 0:t.map(function(e){return"".concat(e).concat(e)}))||void 0===n?void 0:n.join(""):i;if(6===(null==o?void 0:o.length)){var r=parseInt(null==o?void 0:o.slice(0,2),16),a=parseInt(null==o?void 0:o.slice(2,4),16),l=parseInt(null==o?void 0:o.slice(4,6),16);return"rgba(".concat(r,", ").concat(a,", ").concat(l,", 0.8)")}}return"#FFFFFF"===e?"rgba(255, 255, 255, 0.8)":"rgba(14, 14, 15, 0.8)"}(r),l=(null==n?void 0:n.button_content)||"Chat on WhatsApp";return e.createElement("div",{className:"rblyn-chat-widget-popup",style:{width:"20rem",maxWidth:"calc(100vw - 20px)",borderRadius:"22px",overflow:"hidden",backgroundColor:"#fff",boxShadow:"0 16px 40px rgba(14, 14, 15, 0.2)",marginBottom:"14px"}},e.createElement("style",null,"\n .rblyn-chat-widget-popup,\n .rblyn-chat-widget-popup * {\n font-family: ".concat(b," !important;\n }\n .rblyn-chat-widget-powered-link {\n text-decoration: none;\n }\n .rblyn-chat-widget-powered-link:hover {\n text-decoration: underline;\n color: rgba(14, 14, 15, 0.8) !important;\n }\n ")),e.createElement("div",{style:{backgroundColor:o,padding:"20px 18px 16px"}},e.createElement("div",{style:{color:r,fontSize:"16px",fontWeight:600,lineHeight:"1.2"}},(null==n?void 0:n.widget_title)||"Hi there"),e.createElement("div",{style:{color:a,fontSize:"12px",marginTop:"4px"}},(null==n?void 0:n.widget_subtitle)||"We typically reply in minutes")),e.createElement("div",{style:{padding:"20px 16px 22px"}},e.createElement("button",{onClick:i,style:{width:"100%",border:"none",borderRadius:"14px",backgroundColor:(null==n?void 0:n.brand_colour)||"#25D366",color:h((null==n?void 0:n.brand_colour)||"#25D366"),fontSize:"14px",fontWeight:600,padding:"14px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"}},e.createElement("img",{src:"https://cdn.robylon.ai/logos/WhatsApp.svg",alt:"WhatsApp",style:{width:"20px",height:"20px",objectFit:"contain"}}),e.createElement("span",null,l)),(null==n?void 0:n.powered_by_robylon)?e.createElement("div",{style:{textAlign:"center",color:"rgba(14, 14, 15, 0.4)",fontSize:"14px",marginTop:"14px"}},"Powered by"," ",e.createElement("a",{href:"https://www.robylon.ai",target:"_blank",rel:"noopener noreferrer",className:"rblyn-chat-widget-powered-link"},"Robylon")):null))},Ye=function(){var e;return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platform)||(/Windows|Mac|Linux|Android|iOS/.exec(navigator.userAgent)||["Unknown"])[0]},Ke=function(){var e;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands)for(var t=["Chrome","Firefox","Safari","Edge","Opera"],n=0,i=navigator.userAgentData.brands;n<i.length;n++){var o=i[n];if(t.includes(o.brand))return o.brand}return(/Chrome|Firefox|Safari|Edge|Opera/.exec(navigator.userAgent)||["Unknown"])[0]},Je=function(){var e,t,n,i;return{width:(null===window||void 0===window?void 0:window.innerWidth)||(null===(e=null===document||void 0===document?void 0:document.documentElement)||void 0===e?void 0:e.clientWidth)||(null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.clientWidth),height:(null===window||void 0===window?void 0:window.innerHeight)||(null===(n=null===document||void 0===document?void 0:document.documentElement)||void 0===n?void 0:n.clientHeight)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.clientHeight)}},qe=function(){return{platform:"web",os:Ye(),browser:Ke(),sdk_version:"1.0.1",device:(e=navigator.userAgent.toLowerCase(),/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"),screen_size:Je()};var e};v.log("Raw API_URL:","https://api.robylon.ai");var Ze={copilotUrl:"https://chatbot.robylon.ai",environment:"production",apiUrl:"https://api.robylon.ai"};v.log("CONFIG",Ze);var Qe,$e=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},et=function(){return{copilotUrl:Ze.copilotUrl||"https://app.robylon.ai",environment:Ze.environment||"production",apiUrl:Ze.apiUrl||"https://app.robylon.ai"}};!function(e){e.ERROR="ERROR",e.INFO="INFO"}(Qe||(Qe={}));var tt,nt=["@robylon/whatsapp-react-sdk","node_modules/@robylon/whatsapp-react-sdk/"],it=function(e){var t=e.filename,n=e.stack,i=e.message;return!!(t||n||i)&&nt.some(function(e){return(null==t?void 0:t.includes(e))||(null==n?void 0:n.includes(e))||(null==i?void 0:i.includes(e))})},ot=function(){function e(){var e=this;this.apiKey="",this.userId=null,this.preInitQueue=[],this.isInitialized=!1,this.handleWindowError=function(t){var n,i={filename:t.filename,stack:null===(n=t.error)||void 0===n?void 0:n.stack,message:t.message};it(i)&&e.trackError(t.error||t.message,"GlobalErrorHandler",{filename:t.filename,lineNo:t.lineno,colNo:t.colno})},this.handleUnhandledRejection=function(t){var n,i,o={stack:null===(n=t.reason)||void 0===n?void 0:n.stack,message:(null===(i=t.reason)||void 0===i?void 0:i.message)||String(t.reason)};it(o)&&e.trackError(t.reason||"Unhandled Promise Rejection","GlobalPromiseHandler",{reason:t.reason})},this.setupGlobalHandlers()}return e.prototype.setupGlobalHandlers=function(){$e()&&(null===window||void 0===window||window.addEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.addEventListener("unhandledrejection",this.handleUnhandledRejection))},e.prototype.cleanup=function(){$e()&&(null===window||void 0===window||window.removeEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.removeEventListener("unhandledrejection",this.handleUnhandledRejection))},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.initialize=function(e,t){void 0===t&&(t=null);try{if(this.preInitQueue.length>0){var n={org_id:"UNINITALIZED",event_data:{message:"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e)),componentName:"ErrorTrackingService",additionalInfo:{preInitError:!0,apiKey:e,userId:t,timestamp:Date.now()},timestamp:Date.now()},metadata:qe(),event_type:Qe.ERROR,user_id:t};this.sendLog(n).catch(console.error)}this.apiKey=e,this.userId=t,this.isInitialized=!0,this.processPreInitQueue()}catch(n){v.error("Error during ErrorTrackingService initialization:",n),this.preInitQueue.push({error:n instanceof Error?n:new Error(String(n)),componentName:"ErrorTrackingService",additionalInfo:{apiKey:e,userId:t}})}},e.prototype.processPreInitQueue=function(){return d(this,void 0,void 0,function(){var e,t,n;return u(this,function(i){switch(i.label){case 0:if(!this.preInitQueue.length)return[2];v.info("Processing ".concat(this.preInitQueue.length," pre-initialization errors")),e=0,t=this.preInitQueue,i.label=1;case 1:return e<t.length?(n=t[e],[4,this.trackError(n.error,n.componentName,c(c({},n.additionalInfo),{preInitError:!0}))]):[3,4];case 2:i.sent(),i.label=3;case 3:return e++,[3,1];case 4:return this.preInitQueue=[],[2]}})})},e.prototype.sendLog=function(e){return d(this,void 0,void 0,function(){var t,n,i,o,r,a;return u(this,function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),t=et().apiUrl,[4,fetch("".concat(t,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return(n=l.sent()).ok?[3,3]:(o=(i=v).error,r=["Failed to send error log:"],[4,n.text()]);case 2:o.apply(i,r.concat([l.sent()])),l.label=3;case 3:return[3,5];case 4:return a=l.sent(),v.error("Error sending log:",a),[3,5];case 5:return[2]}})})},e.prototype.trackError=function(e,t,n){return d(this,void 0,void 0,function(){var i,o,r;return u(this,function(a){switch(a.label){case 0:if(this.isInitialized)return[3,5];i={org_id:"UNINITALIZED",event_data:{message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:c(c({},n),{preInitError:!0,timestamp:Date.now()}),timestamp:Date.now()},metadata:qe(),event_type:Qe.ERROR,user_id:this.userId},a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.sendLog(i)];case 2:return a.sent(),[3,4];case 3:return a.sent(),this.preInitQueue.push({error:e,componentName:t,additionalInfo:n}),v.warn("Error tracked before initialization, queuing:",e),[3,4];case 4:return[2];case 5:return o={message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:c(c({},n),{timestamp:Date.now()}),timestamp:Date.now()},r={org_id:this.apiKey||"UNINITALIZED",event_data:o,metadata:qe(),event_type:Qe.ERROR,user_id:this.userId},[4,this.sendLog(r)];case 6:return a.sent(),[2]}})})},e.prototype.trackInfo=function(e,t,n){return d(this,void 0,void 0,function(){var i,o;return u(this,function(r){switch(r.label){case 0:return this.apiKey?(i={message:e,componentName:t,additionalInfo:n,timestamp:Date.now()},o={org_id:this.apiKey,event_data:i,metadata:qe(),event_type:Qe.INFO,user_id:this.userId},[4,this.sendLog(o)]):(v.error("Error tracking not initialized"),[2]);case 1:return r.sent(),[2]}})})},e}(),rt=ot.getInstance(),at="MISSING_API_KEY",lt="INVALID_API_KEY",st="CONFIG_FETCH_FAILED",ct="SDK_INIT_FAILED",dt="ERROR_TRACKING_INIT_FAILED",ut="API_REQUEST_FAILED",pt="NETWORK_ERROR",ft="INVALID_RESPONSE",mt="IFRAME_LOAD_FAILED",ht="COOKIE_ACCESS_ERROR",gt="COMPONENT_RENDER_ERROR",vt="INITIALIZATION_ERROR",yt="API_ERROR",bt="COMPONENT_ERROR",_t=((tt={})[at]=function(e){return"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e),". A valid API key string is required to initialize the SDK.")},tt[lt]=function(e){return"SDK Initialization Failed: Provided API key '".concat(e,"' is invalid. API key must be a non-empty string in UUID format.")},tt[st]=function(e){return"Failed to fetch chatbot configuration: ".concat(e.statusCode?"Server responded with status ".concat(e.statusCode):"Could not reach server").concat(e.error?". Error: ".concat(e.error):"")},tt[ut]=function(e,t,n){return"API Request Failed: Server responded with status ".concat(e," for ").concat(n?"endpoint ".concat(n):"request"," - ").concat(t)},tt[pt]=function(e){return"Network Error: Failed to communicate with server".concat(e.url?" at ".concat(e.url):"").concat(e.error?" - ".concat(e.error):"")},tt[mt]=function(e){return"Failed to load chatbot interface".concat(e.src?" from ".concat(e.src):"").concat(e.error?". Error: ".concat(e.error):"")},tt[ft]=function(e){return"Invalid API Response: Missing required fields in response data: ".concat(e.join(", "))},tt[dt]=function(e){return"Error Tracking Service initialization failed".concat(e.apiKey?" for API key ".concat(e.apiKey):"").concat(e.error?". Error: ".concat(e.error):"")},tt[ct]=function(e){return"SDK Initialization Failed: ".concat(e.reason||"Could not initialize the chatbot SDK").concat(e.config?". Attempted initialization with config: ".concat(JSON.stringify(e.config,null,2)):"")},tt[ht]=function(e,t){return"Cookie Access Error: Failed to ".concat(e).concat(t?" cookie '".concat(t,"'"):" cookies",". This may affect user session persistence.")},tt[gt]=function(e){return"React Component Error: ".concat(e.component||"Unknown component"," failed to render. Error: ").concat(e.error).concat(e.stack?"\nComponent Stack: ".concat(e.stack):"")},tt),wt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={hasError:!1},t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(n,e),n.getDerivedStateFromError=function(e){return{hasError:!0}},n.prototype.componentDidCatch=function(e,t){rt.trackError(new Error(_t[gt]({component:this.props.componentName||void 0,error:e.message,stack:t.componentStack})),this.props.componentName||void 0,{errorCode:gt,errorType:bt,context:{originalError:e,componentStack:t.componentStack,timestamp:Date.now()}})},n.prototype.render=function(){return this.state.hasError?null:this.props.children},n}(e.Component),xt=function(e){var t=e?"USER_DATA=%7B%22attributes%22%3A%5B%7B%22key%22%3A%22USER_ATTRIBUTE_USER_EMAIL%22%2C%22value%22%3A%22dinesh.goel%40robylon.ai%22%7D%2C%7B%22key%22%3A%22USER_ATTRIBUTE_UNIQUE_ID%22%2C%22value%22%3A%2266011f2c28d1787d13c6c796%22%7D%5D%2C%22subscribedToOldSdk%22%3Afalse%2C%22deviceUuid%22%3A%2226c02feb-2664-451d-8469-9cf1378547c6%22%2C%22deviceAdded%22%3Atrue%7D; _ga_3YS9P6ZDWX=GS1.1.1715252584.3.1.1715258696.39.0.0; _ga_V4J24F7YF9=GS1.1.1715273274.2.0.1715273274.0.0.0; city_name=Bengaluru; lang_code=en-in; cookieConcent=A; _gcl_au=1.1.343275043.1717154298; _clck=43guwd%7C2%7Cfmi%7C0%7C1561; _gid=GA1.2.1423066649.1718210058; moe_uuid=26c02feb-2664-451d-8469-9cf1378547c6; _ga_6RM65PWEZY=GS1.1.1718210058.18.1.1718211647.60.0.0; _ga=GA1.1.689213983.1712737672; AMP_MKTG_fe4beb374f=JTdCJTIycmVmZXJyZXIlMjIlM0ElMjJodHRwcyUzQSUyRiUyRmFjY291bnRzLnRlYWNobWludC5jb20lMkYlMjIlMkMlMjJyZWZlcnJpbmdfZG9tYWluJTIyJTNBJTIyYWNjb3VudHMudGVhY2htaW50LmNvbSUyMiU3RA==; AMP_fe4beb374f=JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjI0MWMxMTljZC03YzVjLTRiYTctYTUzZS1mYTgzMjRlYjc0OWUlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxZjI2ODAwOC01OGYxLTQwYTItYjQ0Ni1mYmQ5N2E0NDQyYTAlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzE4MjEzMzEwOTc3JTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRUaW1lJTIyJTNBMTcxODIxMzMxMDk4MSUyQyUyMmxhc3RFdmVudElkJTIyJTNBMTQlN0Q=; _ga_3YS9P6ZDWX=GS1.1.1718211637.26.1.1718213441.60.0.0; SESSION=%7B%22sessionKey%22%3A%22e4d76f52-9053-4277-99a4-f1ba667fd5f2%22%2C%22sessionStartTime%22%3A%222024-06-12T16%3A34%3A19.047Z%22%2C%22sessionMaxTime%22%3A1800%2C%22customIdentifiersToTrack%22%3A%5B%5D%2C%22sessionExpiryTime%22%3A1718215247464%2C%22numberOfSessions%22%3A17%7D":document.cookie;return t=t.split(";").map(function(e){var t=e.split("="),n=t[0],i=t.slice(1).join("=").trim();return{name:n=n.trim(),value:i?decodeURIComponent(i):""}}),t},Et=function(){var e,t=navigator.userAgent;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands){var n=navigator.userAgentData.brands.find(function(e){return"Google Chrome"===e.brand});if(null==n?void 0:n.version)return n.version}var i=t.match(/(Chrome|Firefox|Safari|Edge|Opera)\/(\d+\.\d+)/);return i?i[2]:"Unknown"},Tt=function(){var e,t,n=qe();return{current_page_url:(null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href)||"",browser_language:(null===navigator||void 0===navigator?void 0:navigator.language)||(null===(t=null===navigator||void 0===navigator?void 0:navigator.languages)||void 0===t?void 0:t[0])||"en",browser_version:Et(),os:null==n?void 0:n.os,referral_url:(null===document||void 0===document?void 0:document.referrer)||"",system_info:n}},It="https://cdn.robylon.ai/logos/WhatsApp.svg",Ct=function(){function e(e){this.logoContainer=null,this.iframe=null,this.bubblePromptContainer=null,this.chatBtnImage=null,this.config=e,this.validateDomain()&&this.init(),null===window||void 0===window||window.addEventListener("message",this.onCloseListener.bind(this),!1)}return e.prototype.onCloseListener=function(e){e.origin===this.config.domain&&"closeChatbot"===e.data&&this.closeIframe()},e.prototype.validateDomain=function(){var e,t=this.config.domain,n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.origin;return v.log("expectedDomain, to current domain",t,n,t===n),t===n},e.prototype.createChatBubblContainer=function(){var e,t=this,n=document.createElement("div");n.id="chatbase-message-bubbles",Object.assign(n.style,{position:"fixed",bottom:"80px",borderRadius:"10px",fontFamily:"sans-serif",fontSize:"16px",zIndex:"2147483644",cursor:"pointer",flexDirection:"column",gap:"50px",maxWidth:"70vw",display:"block",right:"1rem",left:"unset"});var i=document.createElement("div");i.classList.add("close-btn"),i.textContent="✕",Object.assign(i.style,{position:"absolute",top:"-7px",right:"-7px",fontWeight:"bold",display:"none",justifyContent:"center",alignItems:"center",zIndex:"2147483643",width:"22px",height:"22px",borderRadius:"50%",textAlign:"center",fontSize:"12px",cursor:"pointer",backgroundColor:"rgb(224, 224, 224)",color:"black",boxShadow:"rgba(150, 150, 150, 0.15) 0px 6px 24px 0px, rgba(150, 150, 150, 0.15) 0px 0px 0px 1px"}),((null===(e=this.config.chat_interface_config)||void 0===e?void 0:e.chat_bubble_prompts)||[]).forEach(function(e){var i=t.createMessageBubble(e);n.appendChild(i)}),n.appendChild(i),document.body.appendChild(n)},e.prototype.createMessageBubble=function(e){var t=document.createElement("div");this.bubblePromptContainer=t,Object.assign(t.style,{display:"flex",position:"relative",justifyContent:"flex-end"});var n=document.createElement("div");n.classList.add("message"),n.textContent=e,Object.assign(n.style,{backgroundColor:"white",color:"black",boxShadow:"rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px",borderRadius:"10px",padding:"8px 5px",margin:"8px",fontSize:"14px",opacity:"1",transform:"scale(1)",transition:"opacity 0.5s ease 0s, transform 0.5s ease 0s"});var i=document.createElement("button");return i.innerHTML="×",Object.assign(i.style,{position:"absolute",top:"1px",left:"-3px",width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#fff",color:"#000",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 5px rgba(0,0,0,0.2)",fontSize:"14px",lineHeight:"1",padding:"0",zIndex:"100"}),i.addEventListener("click",function(){t.remove()}),t.appendChild(i),t.appendChild(n),t},e.prototype.createFloatingButton=function(){var e=document.createElement("div");e.classList.add("message-bubble-container"),Object.assign(e.style,{position:"fixed",bottom:"1.5rem",right:"1.5rem",zIndex:"1000",width:"48px",height:"48px",display:"flex",flexDirection:"column-reverse",backgroundColor:this.config.brand_colour,color:h(this.config.brand_colour),borderRadius:"50%",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden"}),document.body.appendChild(e),this.logoContainer=e,this.loadImage(this.logoContainer),this.createChatBubblContainer(),this.logoContainer.addEventListener("click",this.toggleIframe.bind(this))},e.prototype.loadImage=function(e){var t,n,i,o,r,a,l,s,c,d=document.createElement("img"),u=null!==(n=null===(t=this.config)||void 0===t?void 0:t.launcher_size_multiplier)&&void 0!==n?n:1,p="".concat(Math.max(4,Math.round(4*u)),"px"),f=(null===(i=this.config)||void 0===i?void 0:i.launcher_type)?(null===(l=null===(a=null===(r=null===(o=this.config)||void 0===o?void 0:o.images)||void 0===r?void 0:r.launcher_image_url)||void 0===a?void 0:a.url)||void 0===l?void 0:l.trim())||It:(null===(c=null===(s=this.config)||void 0===s?void 0:s.image_url)||void 0===c?void 0:c.trim())||It,m=f===It;d.src=f,d.alt="Chat",Object.assign(d.style,{zIndex:"1000",cursor:"pointer",borderRadius:m?"0":"50%",objectFit:m?"contain":"cover",padding:m?p:"0",boxSizing:"border-box",width:m?"calc(100% - 3px)":"100%",height:m?"calc(100% - 3px)":"100%",margin:m?"4px":"0"}),this.chatBtnImage=d,e.innerHTML="",e.appendChild(d)},e.prototype.createIframe=function(){var e=this;v.log("RobylonConfig?.domain====>",this.config.domain);var t=document.createElement("iframe");Object.assign(t.style,{position:"fixed",right:"32px",bottom:"86px",minWidth:"400px",width:"26%",maxWidth:"800px",top:"calc(10vh - 32px)",maxHeight:"45rem",height:"calc(100vh - 3rem - 10vh)",zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom right",transition:"transform 0.3s ease-out",borderRadius:"1rem",display:"none"}),t.src="".concat(this.config.domain,"/chatbot-plugin?id=").concat(this.config.chatbotId),v.log("iframe.src====>",t.src),document.body.appendChild(t),this.iframe=t;var n=function(){(null===window||void 0===window?void 0:window.innerWidth)<560?Object.assign(t.style,{width:"100vw",minWidth:"300px",right:"0",bottom:"0",height:"100vh",flexDirection:"column",flexGrow:"1",borderRadius:"0",top:"0",maxHeight:"100%"}):Object.assign(t.style,{width:"26%",minWidth:"400px",right:"32px",bottom:"86px",height:"calc(100vh - 3rem - 10vh)",borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"45rem"})};n(),null===window||void 0===window||window.addEventListener("resize",n),t.addEventListener("load",function(){var n,i,o,r,a;if(e.iframe){var l=new URL(e.iframe.src).origin||e.config.domain;null===(n=t.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},l),null===(o=t.contentWindow)||void 0===o||o.postMessage({domain:null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hostname,action:"registerUserId",data:{userId:e.config.userId,token:e.config.token,userProfile:c(c({},e.config.userProfile||{}),{__INT_SYS_INFO__:c(c({},(null===(a=e.config.userProfile)||void 0===a?void 0:a.__INT_SYS_INFO__)||{}),Tt())})}},l)}}),null===window||void 0===window||window.addEventListener("message",function(n){var i,o;if(n.origin===e.config.domain){if("captureSessionData"===n.data){var r="66b33d16-5b38-4693-8772-1a1bd7dd412d"===e.config.chatbotId,a={cookies:xt(r),localStorage:JSON.stringify(localStorage),sessionStorage:JSON.stringify(sessionStorage),action:"capturedSessionData",domain_name:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname};null===(o=t.contentWindow)||void 0===o||o.postMessage(a,e.config.domain||"*")}"expand"===n.data&&(e.adjustIframeWidth(),t.style.height="calc(100vh - 120px)",t.style.bottom="86px"),"collapse"===n.data&&Object.assign(t.style,{width:"26%",height:"calc(100vh - 32px - 10vh)",bottom:"86px",top:"calc(32px + 10vh)"})}})},e.prototype.adjustIframeWidth=function(){if(this.iframe){var e=null===window||void 0===window?void 0:window.innerWidth;v.log("screenWidth",e),this.iframe.style.width=e<832?"".concat(e-64,"px"):"800px"}},e.prototype.loadSvgInline=function(e){var t=document.createElement("div");t.innerHTML='\n<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g id="Chevron_Down">\n <path id="Vector" d="M19 9L12 16L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n </g>\n</svg>\n';var n=t.querySelector("svg");e.innerHTML="",n&&e.appendChild(n)},e.prototype.toggleIcon=function(e,t){"block"===t.style.display?this.loadSvgInline(e):this.loadImage(e)},e.prototype.toggleIframe=function(){var e,t;if(v.log("toggleIframe",this.iframe,this.logoContainer,this.chatBtnImage),this.iframe&&this.logoContainer&&this.chatBtnImage){var n=new URL(this.iframe.src).origin||this.config.domain;v.log("toggleIframe"),null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage({domain:null===window||void 0===window?void 0:window.location.hostname,name:"none"===this.iframe.style.display?"openFrame":"closeFrame"},n),this.iframe.style.display="none"===this.iframe.style.display?"block":"none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="block"===this.iframe.style.display?"none":(null===(t=this.chatBtnImage)||void 0===t?void 0:t.src)===It?"contain":"cover",this.bubblePromptContainer&&(this.bubblePromptContainer.style.display="none"),v.log("this.bubblePromptContainer",this.bubblePromptContainer)}},e.prototype.closeIframe=function(){var e;this.iframe&&this.logoContainer&&this.chatBtnImage&&(this.iframe.style.display="none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit=(null===(e=this.chatBtnImage)||void 0===e?void 0:e.src)===It?"contain":"cover")},e.prototype.init=function(){this.createIframe(),this.createFloatingButton()},e}(),St=function(e,t,n){if(e.chatbotId&&e.userId)try{new Ct(e);t(!0),v.log("Robylon SDK initialized successfully.")}catch(e){n(e instanceof Error?e.message:"Failed to initialize SDK")}else n("Incomplete configuration for SDK initialization.")},At=function(e){return function(e){var t,n,i,o,r,a,l,s;return Boolean((null===(i=null===(n=null===(t=null==e?void 0:e.user)||void 0===t?void 0:t.org_info)||void 0===n?void 0:n.brand_config)||void 0===i?void 0:i.widget)&&(null===(s=null===(l=null===(a=null===(r=null===(o=null==e?void 0:e.user)||void 0===o?void 0:o.org_info)||void 0===r?void 0:r.brand_config)||void 0===a?void 0:a.profile)||void 0===l?void 0:l.qr_code)||void 0===s?void 0:s.chat_link))}(e)?function(e){var t,n,i=null===(n=null===(t=null==e?void 0:e.user)||void 0===t?void 0:t.org_info)||void 0===n?void 0:n.brand_config;return{profile:null==i?void 0:i.profile,widget:null==i?void 0:i.widget,business_profile:null==i?void 0:i.business_profile,display_name:null==i?void 0:i.display_name}}(e):e},Ot=function(e,t,n){return d(void 0,void 0,void 0,function(){var i,o,r,a,l,s,c,d,p,f;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),i=et().apiUrl,o="".concat(i,"/chat/whatsapp/get/"),v.log("endpointUrl",o),r={client_user_id:t||null,org_id:e,token:n||void 0,extra_info:{},launcher_info:Tt(),phone_no_id:"739739745898120"},[4,fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify(r)})];case 1:return(a=u.sent()).ok?[3,3]:[4,a.text()];case 2:throw l=u.sent(),new Error(_t[ut](a.status,l));case 3:return[4,a.json()];case 4:if(s=u.sent(),c=At(s),!(null===(f=null===(p=null==c?void 0:c.profile)||void 0===p?void 0:p.qr_code)||void 0===f?void 0:f.chat_link)||!(null==c?void 0:c.widget))throw new Error(_t[ft](["profile","widget"]));return[2,c];case 5:throw d=u.sent(),rt.trackError(d instanceof Error?d:new Error(_t[pt]({error:String(d)})),"fetchChatbotConfig",{errorCode:d instanceof Error&&d.message.includes("API Request Failed")?ut:pt,errorType:yt,context:{apiKey:e,userId:t,timestamp:Date.now()}}),d;case 6:return[2]}})})},kt=function(e){return d(void 0,void 0,void 0,function(){var t,n,i,o,r,a,l,s,d,p,f,m,h,g,y,b,_,w,x,E,T,I,C,S,A,O,k,R,N,D,L,M,z;return u(this,function(u){switch(u.label){case 0:return t=function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(e),n=t.user_id||void 0,i=!1,n||(n=function(e){var t,n="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===n.length)return null===(t=n.pop())||void 0===t?void 0:t.split(";").shift()}("rblyn_anon")||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),B="rblyn_anon",H=n,U=365,(P=new Date).setTime(P.getTime()+24*U*60*60*1e3),document.cookie="".concat(B,"=").concat(H,";expires=").concat(P.toUTCString(),";path=/"),i=!0),[4,Ot(t.api_key,n,t.user_token)];case 1:o=u.sent();try{t.api_key}catch(e){v.warn("Failed to inject mock proactive messages",e)}return r=qe(),a=Tt(),F=t.user_profile,l=F?Object.fromEntries(Object.entries(F).map(function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]})):{},s=c(c(c({},r),{__INT_SYS_INFO__:c(c({},r),a)}),l),d=function(e){if("string"==typeof e)return(null==e?void 0:e.trim())||"";var t=null==e?void 0:e.url;return"string"==typeof t&&(null==t?void 0:t.trim())||""}(null===(p=null==o?void 0:o.widget)||void 0===p?void 0:p.launcher_image),[2,{chatbotId:t.api_key,userId:n,token:t.user_token,isAnonymous:i,domain:"",show_launcher:!0,brand_colour:(null===(f=null==o?void 0:o.widget)||void 0===f?void 0:f.brand_color)||"#25D366",image_url:d,userProfile:s,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(m=null==o?void 0:o.widget)||void 0===m?void 0:m.title)||(null==o?void 0:o.display_name)||"",welcome_message:(null===(h=null==o?void 0:o.widget)||void 0===h?void 0:h.subtitle)||"Hey! What can we help you with today?",redirect_url:(null===(y=null===(g=null==o?void 0:o.profile)||void 0===g?void 0:g.qr_code)||void 0===y?void 0:y.chat_link)||""},launcher_type:(null===(b=null==o?void 0:o.widget)||void 0===b?void 0:b.launcher_type)||exports.LauncherType.IMAGE,launcher_properties:{text:(null===(_=null==o?void 0:o.widget)||void 0===_?void 0:_.launcher_text)||(null===(w=null==o?void 0:o.widget)||void 0===w?void 0:w.button_content)||""},images:{launcher_image_url:{url:d}},proactive_message_obj:void 0,interface_properties:{position:(null===(x=null==o?void 0:o.widget)||void 0===x?void 0:x.position)||exports.WidgetPositionEnums.RIGHT,side_spacing:(null===(E=null==o?void 0:o.widget)||void 0===E?void 0:E.side_spacing)||20,bottom_spacing:(null===(T=null==o?void 0:o.widget)||void 0===T?void 0:T.bottom_spacing)||20},interface_type:exports.ChatbotInterfaceType.WIDGET,launcher_delay:{enabled:!1,delay:0},launcher_size_multiplier:null!==(C=null===(I=null==o?void 0:o.widget)||void 0===I?void 0:I.launcher_size_multiplier)&&void 0!==C?C:1,redirect_chat_link:(null===(A=null===(S=null==o?void 0:o.profile)||void 0===S?void 0:S.qr_code)||void 0===A?void 0:A.chat_link)||"",pre_filled_message:(null===(k=null===(O=null==o?void 0:o.profile)||void 0===O?void 0:O.qr_code)||void 0===k?void 0:k.pre_filled_message)||"",widget_type:(null===(R=null==o?void 0:o.widget)||void 0===R?void 0:R.widget_type)||"quick_launch",widget_title:(null===(N=null==o?void 0:o.widget)||void 0===N?void 0:N.title)||"",widget_subtitle:(null===(D=null==o?void 0:o.widget)||void 0===D?void 0:D.subtitle)||"",title_bar_color:(null===(L=null==o?void 0:o.widget)||void 0===L?void 0:L.title_bar_color)||"#075E54",button_content:(null===(M=null==o?void 0:o.widget)||void 0===M?void 0:M.button_content)||"Chat on WhatsApp",powered_by_robylon:!1!==(null===(z=null==o?void 0:o.widget)||void 0===z?void 0:z.powered_by_robylon)}]}var F,B,H,U,P})})},Rt=function(t){var n=e.useMemo(function(){return function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(t)},[t.api_key,t.user_id,t.user_token,JSON.stringify(t.user_profile)]),i=e.useState({isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1}),o=i[0],r=i[1],a=e.useMemo(function(){return n.user_profile?Object.fromEntries(Object.entries(n.user_profile).map(function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]})):{}},[JSON.stringify(n.user_profile)]),l=e.useCallback(function(e){r(function(t){return c(c({},t),e)})},[]),s=e.useCallback(function(){return d(void 0,void 0,void 0,function(){var e,t,i,o;return u(this,function(r){switch(r.label){case 0:if(!n.api_key)return rt.trackError(new Error(_t[at](n.api_key)),"useChatbotState",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}}),[2];l({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,kt(n)];case 2:return e=r.sent(),t=c(c(c({},qe()),null==e?void 0:e.userProfile),a),e.userProfile=t,[4,new Promise(function(t,n){St(e,function(){l({isInitialized:!0,chatbotConfig:e}),t()},function(e){n(e)})})];case 3:return r.sent(),[3,6];case 4:return i=r.sent(),o=i instanceof Error?i.message:"Failed to initialize chatbot",l({error:o}),rt.trackError(i instanceof Error?i:new Error(o),"useChatbotState",{errorCode:ct,errorType:vt,context:{timestamp:Date.now()}}),[3,6];case 5:return l({isInitializing:!1}),[7];case 6:return[2]}})})},[n.api_key,n.user_id,n.user_token]);e.useEffect(function(){n.api_key&&s()},[s]),e.useEffect(function(){o.chatbotConfig&&r(function(e){return c(c({},e),{chatbotConfig:c(c({},e.chatbotConfig),{userProfile:c(c({},qe()),a)})})})},[a]);var p=e.useCallback(function(){r(function(e){return c(c({},e),{isIframeVisible:!e.isIframeVisible})})},[]),f=e.useCallback(function(){l({isIframeVisible:!1})},[]);return c(c({},o),{toggleIframeVisibility:p,closeIframe:f})},Nt=function(t){var n,i,o,r,a,l,s,d=t.children,u=t.config,p=t.position,f=t.sideSpacing,m=t.bottomSpacing,h=e.useState(!1),g=h[0],y=h[1];e.useEffect(function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);var b=p||(null===(o=u.interface_properties)||void 0===o?void 0:o.position)||"Right",_=null!==(a=null!=f?f:null===(r=u.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,w=null!==(s=null!=m?m:null===(l=u.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==s?s:20;v.log("config",u,b,_);var x={position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column"},E=c(c({},x),((n={bottom:"".concat(w,"px")})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),n.alignItems="Right"===b?"flex-end":"flex-start",n.top=void 0,n["Right"===b?"left":"right"]=void 0,n)),T=c(c({},x),((i={top:0})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),i.alignItems="center",i.bottom=void 0,i["Right"===b?"left":"right"]=void 0,i)),I=g?T:E;return e.useEffect(function(){console.log("Container screen width changed, isMobile:",g,"Style:",I)},[g,I]),e.createElement("div",{className:"robylon-chatbot-container",style:I},d)},Dt=e.forwardRef(function(t,n){var i,o,r,a=t.api_key,l=t.user_id,s=t.user_token,m=t.user_profile,h=t.onEvent,g=t.position,y=t.sideSpacing,b=t.bottomSpacing,_=t.show_launcher,w=t.launcher_type,x=t.launcher_properties_text;t.overrides;var E=t.launcher_size,T="string"==typeof y?""===y||isNaN(Number(y))?void 0:Number(y):y,I="string"==typeof b?""===b||isNaN(Number(b))?void 0:Number(b):b,C="string"==typeof g?"left"===g.toLowerCase()?"Left":"right"===g.toLowerCase()?"Right":void 0:g;e.useEffect(function(){});var S=e.useMemo(function(){return{api_key:a,user_id:l,user_token:s,user_profile:m}},[a,l,s,m]),A=e.useCallback(function(e){null==h||h(e)},[h]),O=Rt(S),k=O.isInitialized,R=O.error,N=O.chatbotConfig,D=O.isIframeVisible,L=O.toggleIframeVisibility,M=O.closeIframe,z=e.useMemo(function(){return{api_key:a,user_profile:S.user_profile,onEvent:A,chatbotConfig:N?{isAnonymous:N.isAnonymous,userId:N.userId}:null}},[a,S.user_profile,A,null==N?void 0:N.isAnonymous,null==N?void 0:N.userId]),F=function(t){var n=t.api_key,i=t.chatbotConfig,o=t.user_profile,r=t.onEvent,a=e.useMemo(function(){return{isAnonymous:(null==i?void 0:i.isAnonymous)||!1,userId:(null==i?void 0:i.userId)||""}},[null==i?void 0:i.isAnonymous,null==i?void 0:i.userId]),l=e.useMemo(function(){return o||{}},[JSON.stringify(o)]),s=e.useCallback(function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return d(void 0,p([e],t,!0),void 0,function(e,t){var i,o,r,s,d,p,f;return void 0===t&&(t={}),u(this,function(u){switch(u.label){case 0:if(!n)return[2];u.label=1;case 1:return u.trys.push([1,3,,4]),i=et().apiUrl,o=qe(),r=c({trigger_time:Date.now(),channel:"CHATBOT",launch_url:(null===(f=null===window||void 0===window?void 0:window.location)||void 0===f?void 0:f.href)||"",org_id:n,client_user_id:a.isAnonymous?"Anonymous":String(a.userId),event_type:e,user_profile:l},t),s={org_id:n,event_data:r,metadata:c({timestamp:Date.now()},o),event_type:"INFO",user_id:a.userId},[4,fetch("".concat(i,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})];case 2:if(!(d=u.sent()).ok)throw new Error("Failed to send internal event: ".concat(d.statusText));return[3,4];case 3:return p=u.sent(),v.error("Failed to send internal event:",p),[3,4];case 4:return[2]}})})},[n,a]);return{emitEvent:e.useCallback(function(e,t){var n=Date.now();e!==f.CHATBOT_BUTTON_CLICKED&&e!==f.CHATBOT_CLOSED&&e!==f.CHATBOT_OPENED&&e!==f.CHATBOT_READY||(r&&r({type:e,timestamp:n,data:t}),s(e,{timestamp:n}))},[r,s]),onInternalEvent:s}}(c({},z)),B=F.emitEvent,H=F.onInternalEvent;e.useImperativeHandle(n,function(){return{show:function(){k&&N?"chat_widget"===(null==N?void 0:N.widget_type)?D||(L(),B(f.CHATBOT_BUTTON_CLICKED)):(null==N?void 0:N.redirect_chat_link)&&(window.open(null==N?void 0:N.redirect_chat_link,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot show - chatbot not ready yet")},hide:function(){k&&N?"chat_widget"===(null==N?void 0:N.widget_type)&&D&&(M(),B(f.CHATBOT_CLOSED)):console.warn("Robylon Chatbot: Cannot hide - chatbot not ready yet")},toggle:function(){k&&N?"chat_widget"===(null==N?void 0:N.widget_type)?(L(),B(D?f.CHATBOT_CLOSED:f.CHATBOT_BUTTON_CLICKED)):(null==N?void 0:N.redirect_chat_link)&&(window.open(null==N?void 0:N.redirect_chat_link,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot toggle - chatbot not ready yet")},isReady:k&&!!N}},[k,N,D,L,M,B]),e.useEffect(function(){k&&N&&B(f.CHATBOT_READY)},[k,N,B]);var U=e.useState(!1),P=U[0],j=U[1];e.useEffect(function(){var e,t,n,i,o,r,a;if(!(void 0!==_?Boolean(_):null===(e=null==N?void 0:N.show_launcher)||void 0===e||e))return j(!1),function(){a&&clearTimeout(a)};var l=!0===(null===(t=null==N?void 0:N.launcher_delay)||void 0===t?void 0:t.enabled),s=null!==(r=null!==(i=null===(n=null==N?void 0:N.launcher_delay)||void 0===n?void 0:n.seconds)&&void 0!==i?i:null===(o=null==N?void 0:N.launcher_delay)||void 0===o?void 0:o.delay)&&void 0!==r?r:0;return l&&Number(s)>0?(j(!1),a=window.setTimeout(function(){j(!0)},1e3*Number(s))):j(!0),function(){a&&clearTimeout(a)}},[_,null==N?void 0:N.show_launcher,null===(i=null==N?void 0:N.launcher_delay)||void 0===i?void 0:i.enabled,null===(o=null==N?void 0:N.launcher_delay)||void 0===o?void 0:o.seconds,null===(r=null==N?void 0:N.launcher_delay)||void 0===r?void 0:r.delay]),e.useEffect(function(){if(a)try{rt.initialize(a,l)}catch(e){rt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:dt,errorType:vt,context:{timestamp:Date.now()}})}else rt.trackError(new Error(_t[at](a)),"RobylonChatbot",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}})},[a,l]);var W="chat_widget"===(null==N?void 0:N.widget_type),G=e.useCallback(function(){var e=null==N?void 0:N.redirect_chat_link;W?(L(),B(D?f.CHATBOT_CLOSED:f.CHATBOT_BUTTON_CLICKED)):e&&(window.open(e,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED))},[null==N?void 0:N.redirect_chat_link,B,W,D,L]),X=e.useCallback(function(){var e=null==N?void 0:N.redirect_chat_link;e&&(window.open(e,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED)),M()},[null==N?void 0:N.redirect_chat_link,B,M]),V=e.useMemo(function(){var e,t,n,i,o;return{config:N,toggleIframe:G,isIframeVisible:D,onEvent:A,onInternalEvent:H,position:C,sideSpacing:T,bottomSpacing:I,launcher_type:w,launcher_properties_text:x,shouldFadeIn:!0===(null===(e=null==N?void 0:N.launcher_delay)||void 0===e?void 0:e.enabled)&&(null!==(o=null!==(n=null===(t=null==N?void 0:N.launcher_delay)||void 0===t?void 0:t.seconds)&&void 0!==n?n:null===(i=null==N?void 0:N.launcher_delay)||void 0===i?void 0:i.delay)&&void 0!==o?o:0)>0||!1,launcher_size:E}},[N,G,D,A,H,C,T,I,w,x,E]);return v.log("floatingButtonProps",V),a&&!R&&N?e.createElement(wt,{componentName:"RobylonChatbot"},k?e.createElement(Nt,{config:N,position:C,sideSpacing:T,bottomSpacing:I},W&&D?e.createElement(wt,{componentName:"ChatWidgetPopup"},e.createElement(Ve,{config:N,onCtaClick:X})):null,e.createElement(wt,{componentName:"ChatbotFloatingButton"},P?e.createElement(Xe,c({},V)):null)):null):null}),Lt=e.memo(Dt,function(e,t){return e.api_key===t.api_key&&e.user_id===t.user_id&&e.user_token===t.user_token&&JSON.stringify(e.user_profile)===JSON.stringify(t.user_profile)&&e.position===t.position&&e.sideSpacing===t.sideSpacing&&e.bottomSpacing===t.bottomSpacing&&e.show_launcher===t.show_launcher&&e.launcher_type===t.launcher_type&&e.launcher_properties_text===t.launcher_properties_text&&JSON.stringify(e.overrides)===JSON.stringify(t.overrides)&&e.launcher_size===t.launcher_size&&!0}),Mt="https://cdn.robylon.ai/logos/WhatsApp.svg",zt=function(){function e(e){var t=this;this.resizeObserver=null,this.proactiveElement=null,this.urlUnsubscribe=null,this.delayTimers=[],this.config=e,this.buttonElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.render(),this.mount();try{this.buttonElement.style.opacity="0",this.buttonElement.style.transition="transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",requestAnimationFrame(function(){t.buttonElement.style.opacity="1"})}catch(e){}this.setupResizeListener(),this.renderProactiveIfNeeded(),this.urlUnsubscribe=S(function(){t.clearProactiveDelays(),t.renderProactiveIfNeeded(!0)})}return e.prototype.render=function(){var e,t,n=this,i=this.config,o=i.config,r=i.isIframeVisible,a=null!==(e=null==o?void 0:o.launcher_size_multiplier)&&void 0!==e?e:1,l=null!==(t=this.config.launcher_size)&&void 0!==t?t:48*a,s={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97)",transform:r?"scale(0.85)":"scale(1)",fontFamily:y};o.launcher_type===exports.LauncherType.IMAGE&&Object.assign(s,{width:"".concat(l,"px"),height:"".concat(l,"px"),borderRadius:"50%",backgroundColor:o.brand_colour}),this.applyResponsiveStyles(s),this.buttonElement.className="message-bubble-container",this.buttonElement.innerHTML="",this.buttonElement.appendChild(this.createLauncherElement()),this.buttonElement.onclick=function(){n.config.toggleIframe(),n.hideProactiveMessages()},this.renderProactiveIfNeeded()},e.prototype.createLauncherElement=function(){var e,t,n,i,o,r,a=this.config,l=a.config,s=a.isIframeVisible,c=null!==(e=null==l?void 0:l.launcher_size_multiplier)&&void 0!==e?e:1,d=null!==(t=this.config.launcher_size)&&void 0!==t?t:48*c,u="".concat(Math.max(4,Math.round(4*c)),"px"),p=(null==l?void 0:l.launcher_type)?(null===(o=null===(i=null===(n=null==l?void 0:l.images)||void 0===n?void 0:n.launcher_image_url)||void 0===i?void 0:i.url)||void 0===o?void 0:o.trim())||Mt:(null===(r=null==l?void 0:l.image_url)||void 0===r?void 0:r.trim())||Mt,f=p===Mt;switch(console.log("config in floating button",l),l.launcher_type){case exports.LauncherType.TEXT:return this.createTextLauncher();case exports.LauncherType.TEXTUAL_IMAGE:return this.createTextualImageLauncher();case exports.LauncherType.IMAGE:default:if(s){var m=Math.round(.5*d),h=document.createElement("div");Object.assign(h.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"});var g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("width",String(m)),g.setAttribute("height",String(m)),g.setAttribute("viewBox","0 0 24 24"),g.setAttribute("fill","none"),g.setAttribute("xmlns","http://www.w3.org/2000/svg"),g.style.display="block";var v=document.createElementNS("http://www.w3.org/2000/svg","path");return v.setAttribute("d","M19 9L12 16L5 9"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),v.setAttribute("stroke-linecap","round"),v.setAttribute("stroke-linejoin","round"),g.appendChild(v),h.appendChild(g),h}var y=document.createElement("img");return y.src=p,y.alt="Chat",Object.assign(y.style,{zIndex:"1000",cursor:"pointer",borderRadius:f?"0":"50%",objectFit:f?"contain":"cover",padding:f?u:"0",width:f?"calc(100% - 3px)":"100%",height:f?"calc(100% - 3px)":"100%",margin:f?"4px":"0",boxSizing:"border-box"}),y}},e.prototype.createTextLauncher=function(){var e=this.config.config,t=e.brand_colour,n=e.launcher_properties,i=e.launcher_size_multiplier,o=null!=i?i:1,r=void 0!==this.config.launcher_size?void 0:160*o,a=void 0!==this.config.launcher_size?void 0:40*o,l=void 0!==this.config.launcher_size?void 0:14*o,s=void 0!==this.config.launcher_size?void 0:21*o,c=document.createElement("div");Object.assign(c.style,{width:void 0!==r?"".concat(r,"px"):"fit-content",maxWidth:void 0!==r?"".concat(r,"px"):"160px",height:void 0!==a?"".concat(a,"px"):"40px",borderRadius:"9999px",backgroundColor:t,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box"});var d=document.createElement("div");Object.assign(d.style,{flex:"1",minWidth:"0"});var u=document.createElement("p");return Object.assign(u.style,{margin:"0",color:h(t),fontSize:void 0!==l?"".concat(l,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==s?"".concat(s,"px"):_,fontFamily:y,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),u.textContent=(null==n?void 0:n.text)||"",d.appendChild(u),c.appendChild(d),c},e.prototype.createTextualImageLauncher=function(){var e,t,n,i,o,r,a,l=this.config.config,s=l.brand_colour,c=l.launcher_properties,d=l.image_url,u=l.launcher_size_multiplier,p=(null===(t=null===(e=null==this?void 0:this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.launcher_type)?(null===(a=null===(r=null===(o=null===(i=null===(n=null==this?void 0:this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.images)||void 0===o?void 0:o.launcher_image_url)||void 0===r?void 0:r.url)||void 0===a?void 0:a.trim())||Mt:(null==d?void 0:d.trim())||Mt,f=p===Mt,m=null!=u?u:1,g="".concat(Math.max(4,Math.round(4*m)),"px"),v=void 0!==this.config.launcher_size?void 0:174*m,b=void 0!==this.config.launcher_size?void 0:40*m,w=void 0!==this.config.launcher_size?void 0:40*m,x=void 0!==this.config.launcher_size?void 0:14*m,E=void 0!==this.config.launcher_size?void 0:21*m,T=document.createElement("div");Object.assign(T.style,{maxWidth:void 0!==v?"".concat(v,"px"):"13rem",width:"fit-content",height:void 0!==b?"".concat(b,"px"):"40px",borderRadius:"9999px",backgroundColor:s,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:"0",paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box"});var I=document.createElement("div");Object.assign(I.style,{flex:"1",minWidth:"0"});var C=document.createElement("p");Object.assign(C.style,{margin:"0",color:h(s),fontSize:void 0!==x?"".concat(x,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==E?"".concat(E,"px"):_,fontFamily:y,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),C.textContent=(null==c?void 0:c.text)||"";var S=document.createElement("div");Object.assign(S.style,{width:void 0!==w?"".concat(w,"px"):"40px",height:void 0!==w?"".concat(w,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:"0"});var A=document.createElement("img");return A.src=p,A.alt="Chat",Object.assign(A.style,{width:f?"calc(100% - 6px)":"100%",height:f?"calc(100% - 6px)":"100%",margin:f?"3px":"0",borderRadius:f?"0":"50%",objectFit:f?"contain":"cover",padding:f?g:"0",boxSizing:"border-box"}),I.appendChild(C),S.appendChild(A),T.appendChild(I),T.appendChild(S),T},e.prototype.applyResponsiveStyles=function(e){var t,n,i,o,r,a,l,s,d,u=(null===window||void 0===window?void 0:window.innerWidth)<560,p=this.config.config,f=this.config.position||(null===(i=p.interface_properties)||void 0===i?void 0:i.position)||"Right",m=null!==(a=null!==(o=this.config.sideSpacing)&&void 0!==o?o:null===(r=p.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,h=null!==(d=null!==(l=this.config.bottomSpacing)&&void 0!==l?l:null===(s=p.interface_properties)||void 0===s?void 0:s.bottom_spacing)&&void 0!==d?d:20;this.buttonElement.style.position="",this.buttonElement.style.bottom="",this.buttonElement.style.right="",this.buttonElement.style.left="";var g=c(c({},e),u?((t={position:"fixed",bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),t):((n={bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),n));Object.assign(this.buttonElement.style,g)},e.prototype.handleResize=function(){var e,t,n,i=null!==(t=null===(e=this.config.config)||void 0===e?void 0:e.launcher_size_multiplier)&&void 0!==t?t:1,o=null!==(n=this.config.launcher_size)&&void 0!==n?n:48*i,r={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",borderRadius:this.config.config.launcher_type&&this.config.config.launcher_type!==exports.LauncherType.IMAGE?"9999px":"50%",boxSizing:"border-box"};this.config.config.launcher_type===exports.LauncherType.IMAGE&&Object.assign(r,{width:"".concat(o,"px"),height:"".concat(o,"px"),borderRadius:"50%",backgroundColor:this.config.config.brand_colour}),this.applyResponsiveStyles(r)},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.getElement=function(){return this.buttonElement},e.prototype.mount=function(){var e=this;requestAnimationFrame(function(){var t,n;null===(n=(t=e.config).onEvent)||void 0===n||n.call(t,{type:f.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),e.config.onInternalEvent(f.CHATBOT_BUTTON_LOADED)})},e.prototype.update=function(e){this.config.isIframeVisible,this.config=c(c({},this.config),e),this.buttonElement.style.transform=this.config.isIframeVisible?"scale(0.85)":"scale(1)",this.render(),this.renderProactiveIfNeeded()},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.buttonElement&&this.buttonElement.parentNode&&this.buttonElement.parentNode.removeChild(this.buttonElement),this.proactiveElement&&this.proactiveElement.parentElement&&(this.proactiveElement.parentElement.removeChild(this.proactiveElement),this.proactiveElement=null),this.clearProactiveDelays(),this.urlUnsubscribe&&(this.urlUnsubscribe(),this.urlUnsubscribe=null)},e.prototype.clearProactiveDelays=function(){this.delayTimers.forEach(function(e){return clearTimeout(e)}),this.delayTimers=[]},e.prototype.hideProactiveMessages=function(){var e,t,n=this;R();var i=null===(e=this.proactiveElement)||void 0===e?void 0:e.children[0];if(i){var o="Right"===(this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right");Array.from(i.children).forEach(function(e){e.className=o?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"}),setTimeout(function(){n.proactiveElement&&n.proactiveElement.parentElement&&n.proactiveElement.parentElement.removeChild(n.proactiveElement),n.proactiveElement=null,n.clearProactiveDelays()},400)}else this.clearProactiveDelays()},e.prototype.injectAnimationStyles=function(){if(!document.getElementById("rblyn-proactive-animations")){var e=document.createElement("style");e.id="rblyn-proactive-animations",e.textContent="\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .rblyn-proactive-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .rblyn-proactive-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .rblyn-proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .rblyn-proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(y,' !important;\n font-size: inherit !important;\n font-weight: inherit !important;\n line-height: inherit !important;\n color: inherit;\n text-align: inherit;\n list-style: none;\n }\n .rblyn-proactive-message-content p,\n .rblyn-proactive-message-content div,\n .rblyn-proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .rblyn-proactive-message-content p:first-child,\n .rblyn-proactive-message-content div:first-child,\n .rblyn-proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .rblyn-proactive-message-content p:last-child,\n .rblyn-proactive-message-content div:last-child,\n .rblyn-proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .rblyn-proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .rblyn-proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .rblyn-proactive-message-content b,\n .rblyn-proactive-message-content strong {\n font-weight: 600 !important;\n }\n .rblyn-proactive-message-content i,\n .rblyn-proactive-message-content em {\n font-style: italic !important;\n }\n .rblyn-proactive-message-content u {\n text-decoration: underline !important;\n }\n .rblyn-proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n '),document.head.appendChild(e)}},e.prototype.renderProactiveIfNeeded=function(e){var t,n,i,o,r,a,l,s,c,d,u,f,m,g,v,b=this,w=null===(n=null===(t=this.config)||void 0===t?void 0:t.config)||void 0===n?void 0:n.proactive_message_obj;if(Array.isArray(w)&&!this.config.isIframeVisible&&!N()){if(this.injectAnimationStyles(),!this.proactiveElement){var x=document.createElement("div");x.style.position="fixed";var E=null!==(a=null!==(o=this.config.bottomSpacing)&&void 0!==o?o:null===(r=this.config.config.interface_properties)||void 0===r?void 0:r.bottom_spacing)&&void 0!==a?a:20,T=null!==(c=null!==(l=this.config.sideSpacing)&&void 0!==l?l:null===(s=this.config.config.interface_properties)||void 0===s?void 0:s.side_spacing)&&void 0!==c?c:20,I=this.config.position||(null===(d=this.config.config.interface_properties)||void 0===d?void 0:d.position)||"Right",C=null!==(f=null===(u=this.config.config)||void 0===u?void 0:u.launcher_size_multiplier)&&void 0!==f?f:1,S=null!==(m=this.config.launcher_size)&&void 0!==m?m:48*C,A=this.config.config.launcher_type===exports.LauncherType.IMAGE?S:void 0!==this.config.launcher_size?40:40*C;x.style.bottom="".concat(E+A+8,"px"),"Right"===I?x.style.right="".concat(T,"px"):x.style.left="".concat(T,"px"),x.style.maxWidth="22.875rem",x.style.zIndex="2147483646";var O=document.createElement("div");O.style.display="flex",O.style.flexDirection="column",O.style.alignItems="Right"===I?"flex-end":"flex-start";var k=document.createElement("div");k.style.position="absolute",k.style.top="-32px",k.style.width="24px",k.style.height="24px",k.style.borderRadius="50%",k.style.background="#fff",k.style.boxShadow="0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",k.style.display="flex",k.style.alignItems="center",k.style.justifyContent="center",k.style.cursor="pointer",k.style.opacity="0",k.style.visibility="hidden","Right"===(this.config.position||(null===(g=this.config.config.interface_properties)||void 0===g?void 0:g.position)||"Right")?(k.style.right="0px",k.style.left="auto",k.style.transform="translateX(120%) scale(0.95)"):(k.style.left="0px",k.style.right="auto",k.style.transform="translateX(-120%) scale(0.95)"),k.onclick=function(e){e.stopPropagation(),b.hideProactiveMessages()},k.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">\n <path d="M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334" stroke="#444547" stroke-width="0.816326" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',x.appendChild(O),x.appendChild(k),document.body.appendChild(x),this.proactiveElement=x}var R=this.proactiveElement.children[0];R.innerHTML="";var L="Right"===(this.config.position||(null===(v=this.config.config.interface_properties)||void 0===v?void 0:v.position)||"Right");R.style.display="flex",R.style.flexDirection="column",R.style.alignItems=L?"flex-end":"flex-start",this.clearProactiveDelays();var M=z(w);p([],M,!0).sort(function(e,t){return e.delayMs!==t.delayMs?e.delayMs-t.delayMs:e.contentIndex-t.contentIndex});var F=new Map;M.forEach(function(e){var t=F.get(e.delayMs);t||(t={messageIds:[],groups:new Map},F.set(e.delayMs,t)),t.groups.has(e.messageId)||(t.messageIds.push(e.messageId),t.groups.set(e.messageId,[])),t.groups.get(e.messageId).push(e)});var B=void 0!==F.get(0),H=this.proactiveElement.children[1];if(H&&M.length>0){H.style.opacity="0",H.style.visibility="hidden",H.style.transform=L?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var U=function(){if(H){H.style.visibility="visible";var e=R.children.length,t=e>0?10*(e-1):0;H.style.animationDelay="".concat(t,"ms"),H.className=L?"rblyn-proactive-close-enter-right":"rblyn-proactive-close-enter-left"}};if(B){var P=window.setTimeout(U,0);this.delayTimers.push(P)}else{var j=Math.min.apply(Math,Array.from(F.keys()));P=window.setTimeout(U,j);this.delayTimers.push(P)}}else H&&(H.style.opacity="0",H.style.visibility="hidden");var W=0;F.forEach(function(e,t){var n=e.messageIds,i=e.groups,o=window.setTimeout(function(){var e=R.children.length,o=0,r=[];n.forEach(function(e){var t=i.get(e)||[];p([],t,!0).sort(function(e,t){return e.contentIndex-t.contentIndex}).forEach(function(t){r.push({messageId:e,item:t})}),o+=t.length});var a=t>0?p([],r,!0).reverse():r;a.forEach(function(n,i){var r,l=n.item,s=document.createElement("div"),c=l.messageDisplayType===exports.MessageDisplayType.BUTTON;s.style.background=(null==l?void 0:l.messageBubbleBg)||"#ffffff",s.style.color="#111",s.style.borderRadius=c?"100px":"12px",s.style.boxShadow="0 2px 2px 0 rgba(0, 0, 0, 0.08)",s.style.padding="16px",s.style.border="1px solid #F1F2F4",s.style.cursor="pointer",s.style.fontFamily=y,s.style.fontSize="14px",s.style.lineHeight=String(_),s.style.width="fit-content",s.style.maxWidth="100%";var d=0===i,u=i===a.length-1,p=e>0,f=F.has(0),m=!1;0===t?m=!u||d&&p:d&&(p||f)?m=!0:d||(m=!0),m&&(s.style.marginBottom="16px");var g=10*(e+o-1-(0===t?e+W:W));s.className=L?"rblyn-proactive-enter-right":"rblyn-proactive-enter-left",s.style.animationDelay="".concat(g,"ms"),s.style.opacity="0",s.style.transform=L?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var v=document.createElement("div");Object.assign(v.style,{display:"flex",alignItems:"center",gap:"8px"});var w=document.createElement("div");if(w.className="rblyn-proactive-message-content",w.setAttribute("dir",We(l.html)),w.innerHTML=je(l.html),v.appendChild(w),(null==l?void 0:l.urlToGo)&&"string"==typeof l.urlToGo&&""!==l.urlToGo.trim()){var x=document.createElementNS("http://www.w3.org/2000/svg","svg");x.setAttribute("width","16"),x.setAttribute("height","17"),x.setAttribute("viewBox","0 0 16 17"),x.setAttribute("fill","none"),x.setAttribute("xmlns","http://www.w3.org/2000/svg"),Object.assign(x.style,{flexShrink:"0",color:h((null==l?void 0:l.messageBubbleBg)||"#ffffff")});var E=document.createElementNS("http://www.w3.org/2000/svg","g");E.setAttribute("id","External_Link");var T=document.createElementNS("http://www.w3.org/2000/svg","path");T.setAttribute("id","Vector"),T.setAttribute("d","M6.6668 3.83268H5.4668C4.72006 3.83268 4.34642 3.83268 4.0612 3.97801C3.81032 4.10584 3.60649 4.30966 3.47866 4.56055C3.33334 4.84576 3.33334 5.21941 3.33334 5.96615V11.0328C3.33334 11.7795 3.33334 12.1527 3.47866 12.4379C3.60649 12.6888 3.81032 12.893 4.0612 13.0208C4.34614 13.166 4.71933 13.166 5.46461 13.166H10.5354C11.2807 13.166 11.6533 13.166 11.9383 13.0208C12.1891 12.893 12.3937 12.6886 12.5215 12.4377C12.6667 12.1528 12.6667 11.78 12.6667 11.0347V9.83268M13.3333 6.49935V3.16602M13.3333 3.16602H10M13.3333 3.16602L8.66667 7.83268"),T.setAttribute("stroke","currentColor"),T.setAttribute("stroke-width","1.5"),T.setAttribute("stroke-linecap","round"),T.setAttribute("stroke-linejoin","round"),E.appendChild(T),x.appendChild(E),v.appendChild(x)}if(s.appendChild(v),s.onclick=function(){if((null==l?void 0:l.urlToGo)&&"string"==typeof l.urlToGo&&""!==l.urlToGo.trim())window.open(l.urlToGo,"_blank","noopener,noreferrer");else{D({message_id:l.messageId,content_string:l.html||null,content_id:l.contentId||null}),b.config.toggleIframe(),b.hideProactiveMessages();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:l.messageId,content_string:l.html||null,content_id:l.contentId||null}}))}catch(e){}}},0===t)R.appendChild(s);else{R.insertBefore(s,R.firstChild);var I=null===(r=b.proactiveElement)||void 0===r?void 0:r.children[1];if(I&&"visible"===I.style.visibility){var C=R.children.length,S=C>0?10*(C-1):0;I.style.animationDelay="".concat(S,"ms")}}W++})},t);b.delayTimers.push(o)})}else if(this.proactiveElement&&this.proactiveElement.parentElement){var G=this.proactiveElement.children[0],X="Right"===(this.config.position||(null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.position)||"Right");Array.from(G.children).forEach(function(e){e.className=X?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"}),setTimeout(function(){b.proactiveElement&&b.proactiveElement.parentElement&&b.proactiveElement.parentElement.removeChild(b.proactiveElement),b.proactiveElement=null,b.clearProactiveDelays()},400)}else this.proactiveElement=null,this.clearProactiveDelays()},e}(),Ft=function(){function e(e,t,n,i){this.resizeObserver=null,this.containerElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.config={config:e,position:t,sideSpacing:n,bottomSpacing:i},this.render(),this.mount(),this.setupResizeListener()}return e.prototype.render=function(){this.applyStyles(),this.containerElement.className="robylon-chatbot-container"},e.prototype.applyStyles=function(){var e,t,n,i,o,r,a,l,s,d=(null===window||void 0===window?void 0:window.innerWidth)<560,u=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",p=null!==(r=null!==(i=this.config.sideSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.side_spacing)&&void 0!==r?r:20,f=null!==(s=null!==(a=this.config.bottomSpacing)&&void 0!==a?a:null===(l=this.config.config.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==s?s:20;this.containerElement.style.position="",this.containerElement.style.top="",this.containerElement.style.bottom="",this.containerElement.style.right="",this.containerElement.style.left="",this.containerElement.style.alignItems="";var m={position:"fixed",zIndex:"1000",display:"flex",flexDirection:"column"},h=c(c({},m),((e={bottom:"".concat(f,"px")})[u.toLowerCase()]="".concat(p,"px"),e.alignItems="Right"===u?"flex-end":"flex-start",e)),g=c(c({},m),((t={top:"0"})[u.toLowerCase()]="".concat(p,"px"),t.alignItems="center",t));Object.assign(this.containerElement.style,d?g:h)},e.prototype.handleResize=function(){this.applyStyles()},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.mount=function(){document.body.appendChild(this.containerElement)},e.prototype.getElement=function(){return this.containerElement},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.containerElement&&this.containerElement.parentNode&&this.containerElement.parentNode.removeChild(this.containerElement)},e}(),Bt=function(){function e(e){this.config=e,this.popupElement=document.createElement("div"),this.render()}return e.prototype.createTitleBar=function(){var e,t,n,i,o,r,a=(null===(t=null===(e=this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.title_bar_color)||"#075E54",l=h(a),s=function(e){var t,n;if(null==e?void 0:e.startsWith("#")){var i=e.replace("#",""),o=3===(null==i?void 0:i.length)?null===(n=null===(t=null==i?void 0:i.split(""))||void 0===t?void 0:t.map(function(e){return"".concat(e).concat(e)}))||void 0===n?void 0:n.join(""):i;if(6===(null==o?void 0:o.length)){var r=parseInt(null==o?void 0:o.slice(0,2),16),a=parseInt(null==o?void 0:o.slice(2,4),16),l=parseInt(null==o?void 0:o.slice(4,6),16);return"rgba(".concat(r,", ").concat(a,", ").concat(l,", 0.8)")}}return"#FFFFFF"===e?"rgba(255, 255, 255, 0.8)":"rgba(14, 14, 15, 0.8)"}(l),c=document.createElement("div");Object.assign(c.style,{backgroundColor:a,padding:"16px 18px 14px"});var d=document.createElement("div");d.textContent=(null===(i=null===(n=this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.widget_title)||"Hi there",Object.assign(d.style,{color:l,fontSize:"16px",fontWeight:"600",lineHeight:"1.2"});var u=document.createElement("div");return u.textContent=(null===(r=null===(o=this.config)||void 0===o?void 0:o.config)||void 0===r?void 0:r.widget_subtitle)||"We typically reply in minutes",Object.assign(u.style,{color:s,fontSize:"12px",marginTop:"4px"}),c.appendChild(d),c.appendChild(u),c},e.prototype.createContent=function(){var e,t,n,i,o,r,a,l,s=document.createElement("div");Object.assign(s.style,{padding:"20px 16px 16px"});var c=document.createElement("button");Object.assign(c.style,{width:"100%",border:"none",borderRadius:"14px",backgroundColor:(null===(t=null===(e=this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.brand_colour)||"#25D366",color:h((null===(i=null===(n=this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.brand_colour)||"#25D366"),fontSize:"14px",fontWeight:"600",padding:"10px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",letterSpacing:"0.01em"});var d=document.createElement("img");d.src="https://cdn.robylon.ai/logos/WhatsApp.svg",d.alt="WhatsApp",Object.assign(d.style,{width:"20px",height:"20px",objectFit:"contain"});var u=document.createElement("span");if(u.textContent=(null===(r=null===(o=this.config)||void 0===o?void 0:o.config)||void 0===r?void 0:r.button_content)||"Chat on WhatsApp",c.appendChild(d),c.appendChild(u),c.onclick=this.config.onCtaClick,s.appendChild(c),null===(l=null===(a=this.config)||void 0===a?void 0:a.config)||void 0===l?void 0:l.powered_by_robylon){var p=document.createElement("div");Object.assign(p.style,{textAlign:"center",color:"rgba(14, 14, 15, 0.4)",fontSize:"10px",marginTop:"10px"}),p.appendChild(document.createTextNode("Powered by "));var f=document.createElement("a");f.href="https://www.robylon.ai",f.target="_blank",f.rel="noopener noreferrer",f.textContent="Robylon",Object.assign(f.style,{color:"inherit",textDecoration:"none"}),f.addEventListener("mouseenter",function(){f.style.textDecoration="underline",f.style.color="rgba(14, 14, 15, 0.8)"}),f.addEventListener("mouseleave",function(){f.style.textDecoration="none",f.style.color="inherit"}),p.appendChild(f),s.appendChild(p)}return s},e.prototype.render=function(){this.popupElement.innerHTML="",this.popupElement.className="rblyn-chat-widget-popup",Object.assign(this.popupElement.style,{width:"19rem",maxWidth:"calc(100vw - 19rem)",borderRadius:"22px",overflow:"hidden",backgroundColor:"#fff",boxShadow:"0 16px 40px rgba(14, 14, 15, 0.2)",marginBottom:"14px"});var e=document.createElement("style");e.textContent="\n .rblyn-chat-widget-popup,\n .rblyn-chat-widget-popup * {\n font-family: ".concat(b," !important;\n }\n "),this.popupElement.appendChild(e),this.popupElement.appendChild(this.createTitleBar()),this.popupElement.appendChild(this.createContent())},e.prototype.getElement=function(){return this.popupElement},e.prototype.update=function(e){this.config=e,this.render()},e.prototype.destroy=function(){var e;(null===(e=this.popupElement)||void 0===e?void 0:e.parentNode)&&this.popupElement.parentNode.removeChild(this.popupElement)},e}(),Ht=function(e){e.api_key,e.user_profile;var t=e.onEvent;e.chatbotConfig;return{emit:function(e,n){var i={type:e,timestamp:Date.now(),data:n};null==t||t(i)},onInternalEvent:function(e,t){}}},Ut=function(){function e(e){var t=this;this.container=null,this.floatingButton=null,this.launcherDelayTimeout=null,this.popup=null,this.isDestroyed=!1,this.handleStateChange=function(e){var n,i,o,r,a,l,s,c;if(!t.isDestroyed){var d=e.isInitialized,u=e.error,p=e.chatbotConfig,f=e.isIframeVisible,m="chat_widget"===(null==p?void 0:p.widget_type);if(!u&&p&&d){t.eventEmitter=Ht({api_key:t.config.api_key,user_profile:t.config.user_profile,onEvent:t.config.onEvent,chatbotConfig:{isAnonymous:p.isAnonymous,userId:p.userId}}),t.container||(t.container=new Ft(p,t.config.position,t.config.sideSpacing,t.config.bottomSpacing)),m&&f?t.popup?t.popup.update({config:p,onCtaClick:t.handlePopupCta}):(t.popup=new Bt({config:p,onCtaClick:t.handlePopupCta}),null===(i=null===(n=t.container)||void 0===n?void 0:n.getElement())||void 0===i||i.prepend(t.popup.getElement())):t.popup&&(t.popup.destroy(),t.popup=null);var h=void 0!==t.config.show_launcher?Boolean(t.config.show_launcher):null===(o=null==p?void 0:p.show_launcher)||void 0===o||o,g=!0===(null===(r=null==p?void 0:p.launcher_delay)||void 0===r?void 0:r.enabled),v=null!==(c=null!==(l=null===(a=null==p?void 0:p.launcher_delay)||void 0===a?void 0:a.seconds)&&void 0!==l?l:null===(s=null==p?void 0:p.launcher_delay)||void 0===s?void 0:s.delay)&&void 0!==c?c:0,y=function(){if(t.floatingButton)t.floatingButton.update({config:p,isIframeVisible:f,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing,launcher_size:t.config.launcher_size});else if(t.floatingButton=new zt({config:p,toggleIframe:t.toggleIframe,isIframeVisible:f,onEvent:t.config.onEvent,onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing,launcher_size:t.config.launcher_size}),t.floatingButton.getElement&&"function"==typeof t.floatingButton.getElement){var e=t.floatingButton.getElement();e&&t.container&&t.container.getElement().appendChild(e)}};t.launcherDelayTimeout&&(clearTimeout(t.launcherDelayTimeout),t.launcherDelayTimeout=null),h?g&&Number(v)>0&&!t.floatingButton?t.launcherDelayTimeout=window.setTimeout(function(){y(),t.launcherDelayTimeout=null},1e3*Number(v)):y():t.floatingButton&&(t.floatingButton.destroy(),t.floatingButton=null)}}},this.toggleIframe=function(){var e,n,i=t.stateManager.getState(),o=null===(e=null==i?void 0:i.chatbotConfig)||void 0===e?void 0:e.redirect_chat_link;"chat_widget"===(null===(n=null==i?void 0:i.chatbotConfig)||void 0===n?void 0:n.widget_type)?(t.stateManager.toggleIframeVisibility(),t.eventEmitter.emit(i.isIframeVisible?f.CHATBOT_CLOSED:f.CHATBOT_BUTTON_CLICKED)):o&&(window.open(o,"_blank","noopener,noreferrer"),t.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED))},this.handlePopupCta=function(){var e,n=t.stateManager.getState(),i=null===(e=null==n?void 0:n.chatbotConfig)||void 0===e?void 0:e.redirect_chat_link;i&&(window.open(i,"_blank","noopener,noreferrer"),t.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED)),t.stateManager.closeIframe()};var n=c(c({},e),{position:"string"==typeof e.position?"left"===e.position.toLowerCase()?"Left":"right"===e.position.toLowerCase()?"Right":void 0:void 0,sideSpacing:"string"==typeof e.sideSpacing?""===e.sideSpacing||isNaN(Number(e.sideSpacing))?void 0:Number(e.sideSpacing):e.sideSpacing,bottomSpacing:"string"==typeof e.bottomSpacing?""===e.bottomSpacing||isNaN(Number(e.bottomSpacing))?void 0:Number(e.bottomSpacing):e.bottomSpacing,show_launcher:e.show_launcher,overrides:e.overrides,launcher_size:e.launcher_size});if(this.config=n,!e.api_key)throw rt.trackError(new Error(_t[at](e.api_key)),"RobylonChatbot",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}}),new Error("API key is required");try{rt.initialize(e.api_key,e.user_id)}catch(e){rt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:dt,errorType:vt,context:{timestamp:Date.now()}})}this.stateManager=function(e){var t={isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1},n=[],i=function(e){t=c(c({},t),e),n.forEach(function(e){return e(t)})};return{getState:function(){return t},initialize:function(){return d(void 0,void 0,void 0,function(){var t,n,o;return u(this,function(r){switch(r.label){case 0:if(!e.api_key)return rt.trackError(new Error(_t[at](e.api_key)),"ChatbotStateManager",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}}),[2];i({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,kt(e)];case 2:return t=r.sent(),[4,new Promise(function(e,n){St(t,function(){i({isInitialized:!0,chatbotConfig:t}),e()},function(e){n(e)})})];case 3:return r.sent(),[3,6];case 4:return n=r.sent(),o=n instanceof Error?n.message:"Failed to initialize chatbot",i({error:o}),rt.trackError(n instanceof Error?n:new Error(o),"ChatbotStateManager",{errorCode:ct,errorType:vt,context:{timestamp:Date.now()}}),[3,6];case 5:return i({isInitializing:!1}),[7];case 6:return[2]}})})},toggleIframeVisibility:function(){i({isIframeVisible:!t.isIframeVisible})},closeIframe:function(){i({isIframeVisible:!1})},updateState:i,subscribe:function(e){return n.push(e),function(){var t=n.indexOf(e);t>-1&&n.splice(t,1)}},unsubscribe:function(e){var t=n.indexOf(e);t>-1&&n.splice(t,1)}}}({api_key:e.api_key,user_id:e.user_id,user_token:e.user_token,user_profile:e.user_profile}),this.eventEmitter=Ht({api_key:e.api_key,user_profile:e.user_profile,onEvent:e.onEvent,chatbotConfig:null}),this.initialize()}return e.prototype.initialize=function(){return d(this,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.stateManager.initialize()];case 1:return t.sent(),this.stateManager.subscribe(this.handleStateChange),this.handleStateChange(this.stateManager.getState()),[3,3];case 2:return e=t.sent(),rt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot.initialize",{errorCode:ct,errorType:vt,context:{timestamp:Date.now()}}),[3,3];case 3:return[2]}})})},e.prototype.show=function(){var e,t,n=this.stateManager.getState();if("chat_widget"===(null===(e=null==n?void 0:n.chatbotConfig)||void 0===e?void 0:e.widget_type))n.isIframeVisible||(this.stateManager.toggleIframeVisibility(),this.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED));else{var i=null===(t=null==n?void 0:n.chatbotConfig)||void 0===t?void 0:t.redirect_chat_link;i&&(window.open(i,"_blank","noopener,noreferrer"),this.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED))}},e.prototype.hide=function(){var e,t=this.stateManager.getState();"chat_widget"===(null===(e=null==t?void 0:t.chatbotConfig)||void 0===e?void 0:e.widget_type)&&t.isIframeVisible&&(this.stateManager.closeIframe(),this.eventEmitter.emit(f.CHATBOT_CLOSED))},e.prototype.toggle=function(){this.toggleIframe()},e.prototype.destroy=function(){this.isDestroyed=!0,this.floatingButton&&(this.floatingButton.destroy(),this.floatingButton=null),this.launcherDelayTimeout&&(clearTimeout(this.launcherDelayTimeout),this.launcherDelayTimeout=null),this.popup&&(this.popup.destroy(),this.popup=null),this.container&&(this.container.destroy(),this.container=null),this.stateManager.unsubscribe(this.handleStateChange)},e.prototype.getState=function(){return this.stateManager.getState().isInitialized?"initialized":"uninitialized"},e}();function Pt(e){return new Ut(e)}if("undefined"!=typeof window){!function(){if("undefined"!=typeof window){var e=window,t=(null==e?void 0:e.RobylonChatbot)||(null==e?void 0:e.R);if(t&&Array.isArray(t.q)){var n=null;t.q.forEach(function(e){var t=e[0];if("init"===t){var i=e[1]||{};n=Pt(i)}else n&&"function"==typeof n[t]&&n[t]()}),e.RobylonChatbot=function(e){var t=Array.prototype.slice.call(arguments,1);return"init"===e?n=Pt(t[0]||{}):n&&"function"==typeof n[e]?n[e].apply(n,t):void 0},(null==e?void 0:e.R)||(e.R=e.RobylonChatbot),e.RobylonChatbot.getState=function(){return"initialized"},(null==e?void 0:e.R)&&(e.R.getState=e.RobylonChatbot.getState)}}}();var jt=window,Wt=null==jt?void 0:jt.RobylonChatbot;Wt&&!(null==jt?void 0:jt.R)&&(jt.R=Wt)}var Gt={create:Pt,getState:function(){return"initialized"}};exports.Chatbot=Lt,exports.RobylonChatbot=Gt,exports.useChatbot=function(t){var n=e.useState({isLoading:!0,isInitialized:!1,error:null}),i=n[0],o=n[1],r=function(e){o(function(t){return c(c({},t),{isInitialized:e})})},a=function(e){o(function(t){return c(c({},t),{error:e})})};return e.useEffect(function(){!function(){try{St(t,r,a)}catch(e){o(function(t){return c(c({},t),{error:e instanceof Error?e.message:"Failed to initialize SDK",isLoading:!1})})}}()},[t.chatbotId,t.userId]),i};
|
|
3
|
+
const{entries:F,setPrototypeOf:B,isFrozen:H,getPrototypeOf:U,getOwnPropertyDescriptor:P}=Object;let{freeze:j,seal:W,create:G}=Object,{apply:X,construct:V}="undefined"!=typeof Reflect&&Reflect;j||(j=function(e){return e}),W||(W=function(e){return e}),X||(X=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)}),V||(V=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const Y=se(Array.prototype.forEach),K=se(Array.prototype.lastIndexOf),J=se(Array.prototype.pop),q=se(Array.prototype.push),Z=se(Array.prototype.splice),Q=se(String.prototype.toLowerCase),$=se(String.prototype.toString),ee=se(String.prototype.match),te=se(String.prototype.replace),ne=se(String.prototype.indexOf),ie=se(String.prototype.trim),oe=se(Object.prototype.hasOwnProperty),re=se(RegExp.prototype.test),ae=(le=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return V(le,t)});var le;function se(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return X(e,t,i)}}function ce(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Q;B&&B(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(H(t)||(t[i]=e),o=e)}e[o]=!0}return e}function de(e){for(let t=0;t<e.length;t++){oe(e,t)||(e[t]=null)}return e}function ue(e){const t=G(null);for(const[n,i]of F(e)){oe(e,n)&&(Array.isArray(i)?t[n]=de(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=ue(i):t[n]=i)}return t}function pe(e,t){for(;null!==e;){const n=P(e,t);if(n){if(n.get)return se(n.get);if("function"==typeof n.value)return se(n.value)}e=U(e)}return function(){return null}}const fe=j(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),me=j(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),he=j(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),ge=j(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ve=j(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ye=j(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),be=j(["#text"]),_e=j(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),we=j(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xe=j(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ee=j(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Te=W(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ie=W(/<%[\w\W]*|[\w\W]*%>/gm),Ce=W(/\$\{[\w\W]*/gm),Se=W(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ae=W(/^aria-[\-\w]+$/),Oe=W(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ke=W(/^(?:\w+script|data):/i),Re=W(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ne=W(/^html$/i),De=W(/^[a-z][.\w]*(-[.\w]+)+$/i);var Le=Object.freeze({__proto__:null,ARIA_ATTR:Ae,ATTR_WHITESPACE:Re,CUSTOM_ELEMENT:De,DATA_ATTR:Se,DOCTYPE_NAME:Ne,ERB_EXPR:Ie,IS_ALLOWED_URI:Oe,IS_SCRIPT_OR_DATA:ke,MUSTACHE_EXPR:Te,TMPLIT_EXPR:Ce});const Me=1,ze=3,Fe=7,Be=8,He=9,Ue=function(){return"undefined"==typeof window?null:window};var Pe=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ue();const n=t=>e(t);if(n.version="3.3.3",n.removed=[],!t||!t.document||t.document.nodeType!==He||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,r=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:l,Node:s,Element:c,NodeFilter:d,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:m}=t,h=c.prototype,g=pe(h,"cloneNode"),v=pe(h,"remove"),y=pe(h,"nextSibling"),b=pe(h,"childNodes"),_=pe(h,"parentNode");if("function"==typeof l){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let w,x="";const{implementation:E,createNodeIterator:T,createDocumentFragment:I,getElementsByTagName:C}=i,{importNode:S}=o;let A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof F&&"function"==typeof _&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:k,TMPLIT_EXPR:R,DATA_ATTR:N,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:L,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:z}=Le;let{IS_ALLOWED_URI:B}=Le,H=null;const U=ce({},[...fe,...me,...he,...ve,...be]);let P=null;const W=ce({},[..._e,...we,...xe,...Ee]);let X=Object.seal(G(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,le=null;const se=Object.seal(G(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let de=!0,Te=!0,Ie=!1,Ce=!0,Se=!1,Ae=!0,ke=!1,Re=!1,De=!1,Pe=!1,je=!1,We=!1,Ge=!0,Xe=!1,Ve=!0,Ye=!1,Ke={},Je=null;const qe=ce({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ze=null;const Qe=ce({},["audio","video","img","source","image","track"]);let $e=null;const et=ce({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",it="http://www.w3.org/1999/xhtml";let ot=it,rt=!1,at=null;const lt=ce({},[tt,nt,it],$);let st=ce({},["mi","mo","mn","ms","mtext"]),ct=ce({},["annotation-xml"]);const dt=ce({},["title","style","font","a","script"]);let ut=null;const pt=["application/xhtml+xml","text/html"];let ft=null,mt=null;const ht=i.createElement("form"),gt=function(e){return e instanceof RegExp||e instanceof Function},vt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!mt||mt!==e){if(e&&"object"==typeof e||(e={}),e=ue(e),ut=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ft="application/xhtml+xml"===ut?$:Q,H=oe(e,"ALLOWED_TAGS")?ce({},e.ALLOWED_TAGS,ft):U,P=oe(e,"ALLOWED_ATTR")?ce({},e.ALLOWED_ATTR,ft):W,at=oe(e,"ALLOWED_NAMESPACES")?ce({},e.ALLOWED_NAMESPACES,$):lt,$e=oe(e,"ADD_URI_SAFE_ATTR")?ce(ue(et),e.ADD_URI_SAFE_ATTR,ft):et,Ze=oe(e,"ADD_DATA_URI_TAGS")?ce(ue(Qe),e.ADD_DATA_URI_TAGS,ft):Qe,Je=oe(e,"FORBID_CONTENTS")?ce({},e.FORBID_CONTENTS,ft):qe,V=oe(e,"FORBID_TAGS")?ce({},e.FORBID_TAGS,ft):ue({}),le=oe(e,"FORBID_ATTR")?ce({},e.FORBID_ATTR,ft):ue({}),Ke=!!oe(e,"USE_PROFILES")&&e.USE_PROFILES,de=!1!==e.ALLOW_ARIA_ATTR,Te=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Se=e.SAFE_FOR_TEMPLATES||!1,Ae=!1!==e.SAFE_FOR_XML,ke=e.WHOLE_DOCUMENT||!1,Pe=e.RETURN_DOM||!1,je=e.RETURN_DOM_FRAGMENT||!1,We=e.RETURN_TRUSTED_TYPE||!1,De=e.FORCE_BODY||!1,Ge=!1!==e.SANITIZE_DOM,Xe=e.SANITIZE_NAMED_PROPS||!1,Ve=!1!==e.KEEP_CONTENT,Ye=e.IN_PLACE||!1,B=e.ALLOWED_URI_REGEXP||Oe,ot=e.NAMESPACE||it,st=e.MATHML_TEXT_INTEGRATION_POINTS||st,ct=e.HTML_INTEGRATION_POINTS||ct,X=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(X.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(X.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(X.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Se&&(Te=!1),je&&(Pe=!0),Ke&&(H=ce({},be),P=G(null),!0===Ke.html&&(ce(H,fe),ce(P,_e)),!0===Ke.svg&&(ce(H,me),ce(P,we),ce(P,Ee)),!0===Ke.svgFilters&&(ce(H,he),ce(P,we),ce(P,Ee)),!0===Ke.mathMl&&(ce(H,ve),ce(P,xe),ce(P,Ee))),oe(e,"ADD_TAGS")||(se.tagCheck=null),oe(e,"ADD_ATTR")||(se.attributeCheck=null),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?se.tagCheck=e.ADD_TAGS:(H===U&&(H=ue(H)),ce(H,e.ADD_TAGS,ft))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?se.attributeCheck=e.ADD_ATTR:(P===W&&(P=ue(P)),ce(P,e.ADD_ATTR,ft))),e.ADD_URI_SAFE_ATTR&&ce($e,e.ADD_URI_SAFE_ATTR,ft),e.FORBID_CONTENTS&&(Je===qe&&(Je=ue(Je)),ce(Je,e.FORBID_CONTENTS,ft)),e.ADD_FORBID_CONTENTS&&(Je===qe&&(Je=ue(Je)),ce(Je,e.ADD_FORBID_CONTENTS,ft)),Ve&&(H["#text"]=!0),ke&&ce(H,["html","head","body"]),H.table&&(ce(H,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ae('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,x=w.createHTML("")}else void 0===w&&(w=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(m,r)),null!==w&&"string"==typeof x&&(x=w.createHTML(""));j&&j(e),mt=e}},yt=ce({},[...me,...he,...ge]),bt=ce({},[...ve,...ye]),_t=function(e){q(n.removed,{element:e});try{_(e).removeChild(e)}catch(t){v(e)}},wt=function(e,t){try{q(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){q(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Pe||je)try{_t(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},xt=function(e){let t=null,n=null;if(De)e="<remove></remove>"+e;else{const t=ee(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ut&&ot===it&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=w?w.createHTML(e):e;if(ot===it)try{t=(new f).parseFromString(o,ut)}catch(e){}if(!t||!t.documentElement){t=E.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?x:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),ot===it?C.call(t,ke?"html":"body")[0]:ke?t.documentElement:r},Et=function(e){return T.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Tt=function(e){return e instanceof p&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},It=function(e){return"function"==typeof s&&e instanceof s};function Ct(e,t,i){Y(e,e=>{e.call(n,t,i,mt)})}const St=function(e){let t=null;if(Ct(A.beforeSanitizeElements,e,null),Tt(e))return _t(e),!0;const i=ft(e.nodeName);if(Ct(A.uponSanitizeElement,e,{tagName:i,allowedTags:H}),Ae&&e.hasChildNodes()&&!It(e.firstElementChild)&&re(/<[/\w!]/g,e.innerHTML)&&re(/<[/\w!]/g,e.textContent))return _t(e),!0;if(e.nodeType===Fe)return _t(e),!0;if(Ae&&e.nodeType===Be&&re(/<[/\w]/g,e.data))return _t(e),!0;if(!(se.tagCheck instanceof Function&&se.tagCheck(i))&&(!H[i]||V[i])){if(!V[i]&&Ot(i)){if(X.tagNameCheck instanceof RegExp&&re(X.tagNameCheck,i))return!1;if(X.tagNameCheck instanceof Function&&X.tagNameCheck(i))return!1}if(Ve&&!Je[i]){const t=_(e)||e.parentNode,n=b(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=g(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,y(e))}}}return _t(e),!0}return e instanceof c&&!function(e){let t=_(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=Q(e.tagName),i=Q(t.tagName);return!!at[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===it?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===i||st[i]):Boolean(yt[n]):e.namespaceURI===tt?t.namespaceURI===it?"math"===n:t.namespaceURI===nt?"math"===n&&ct[i]:Boolean(bt[n]):e.namespaceURI===it?!(t.namespaceURI===nt&&!ct[i])&&!(t.namespaceURI===tt&&!st[i])&&!bt[n]&&(dt[n]||!yt[n]):!("application/xhtml+xml"!==ut||!at[e.namespaceURI]))}(e)?(_t(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!re(/<\/no(script|embed|frames)/i,e.innerHTML)?(Se&&e.nodeType===ze&&(t=e.textContent,Y([O,k,R],e=>{t=te(t,e," ")}),e.textContent!==t&&(q(n.removed,{element:e.cloneNode()}),e.textContent=t)),Ct(A.afterSanitizeElements,e,null),!1):(_t(e),!0)},At=function(e,t,n){if(le[t])return!1;if(Ge&&("id"===t||"name"===t)&&(n in i||n in ht))return!1;if(Te&&!le[t]&&re(N,t));else if(de&&re(D,t));else if(se.attributeCheck instanceof Function&&se.attributeCheck(t,e));else if(!P[t]||le[t]){if(!(Ot(e)&&(X.tagNameCheck instanceof RegExp&&re(X.tagNameCheck,e)||X.tagNameCheck instanceof Function&&X.tagNameCheck(e))&&(X.attributeNameCheck instanceof RegExp&&re(X.attributeNameCheck,t)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(t,e))||"is"===t&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&re(X.tagNameCheck,n)||X.tagNameCheck instanceof Function&&X.tagNameCheck(n))))return!1}else if($e[t]);else if(re(B,te(n,M,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==ne(n,"data:")||!Ze[e]){if(Ie&&!re(L,te(n,M,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&ee(e,z)},kt=function(e){Ct(A.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Tt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P,forceKeepAttr:void 0};let o=t.length;for(;o--;){const r=t[o],{name:a,namespaceURI:l,value:s}=r,c=ft(a),d=s;let u="value"===a?d:ie(d);if(i.attrName=c,i.attrValue=u,i.keepAttr=!0,i.forceKeepAttr=void 0,Ct(A.uponSanitizeAttribute,e,i),u=i.attrValue,!Xe||"id"!==c&&"name"!==c||(wt(a,e),u="user-content-"+u),Ae&&re(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){wt(a,e);continue}if("attributename"===c&&ee(u,"href")){wt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){wt(a,e);continue}if(!Ce&&re(/\/>/i,u)){wt(a,e);continue}Se&&Y([O,k,R],e=>{u=te(u,e," ")});const p=ft(e.nodeName);if(At(p,c,u)){if(w&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(l);else switch(m.getAttributeType(p,c)){case"TrustedHTML":u=w.createHTML(u);break;case"TrustedScriptURL":u=w.createScriptURL(u)}if(u!==d)try{l?e.setAttributeNS(l,a,u):e.setAttribute(a,u),Tt(e)?_t(e):J(n.removed)}catch(t){wt(a,e)}}else wt(a,e)}Ct(A.afterSanitizeAttributes,e,null)},Rt=function e(t){let n=null;const i=Et(t);for(Ct(A.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)Ct(A.uponSanitizeShadowNode,n,null),St(n),kt(n),n.content instanceof a&&e(n.content);Ct(A.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,l=null,c=null;if(rt=!e,rt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!It(e)){if("function"!=typeof e.toString)throw ae("toString is not a function");if("string"!=typeof(e=e.toString()))throw ae("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Re||vt(t),n.removed=[],"string"==typeof e&&(Ye=!1),Ye){if(e.nodeName){const t=ft(e.nodeName);if(!H[t]||V[t])throw ae("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)i=xt("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===Me&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!Pe&&!Se&&!ke&&-1===e.indexOf("<"))return w&&We?w.createHTML(e):e;if(i=xt(e),!i)return Pe?null:We?x:""}i&&De&&_t(i.firstChild);const d=Et(Ye?e:i);for(;l=d.nextNode();)St(l),kt(l),l.content instanceof a&&Rt(l.content);if(Ye)return e;if(Pe){if(je)for(c=I.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(P.shadowroot||P.shadowrootmode)&&(c=S.call(o,c,!0)),c}let u=ke?i.outerHTML:i.innerHTML;return ke&&H["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&re(Ne,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),Se&&Y([O,k,R],e=>{u=te(u,e," ")}),w&&We?w.createHTML(u):u},n.setConfig=function(){vt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Re=!0},n.clearConfig=function(){mt=null,Re=!1},n.isValidAttribute=function(e,t,n){mt||vt({});const i=ft(e),o=ft(t);return At(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&q(A[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=K(A[e],t);return-1===n?void 0:Z(A[e],n,1)[0]}return J(A[e])},n.removeHooks=function(e){A[e]=[]},n.removeAllHooks=function(){A={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),je=function(e){return e?Pe.sanitize(e,{ALLOWED_TAGS:["b","strong","i","em","u","br","span","a","p","s"],ALLOWED_ATTR:["href","target","rel","style"],ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,RETURN_TRUSTED_TYPE:!1}):""};function We(e){if(!e||"string"!=typeof e||0===e.trim().length)return"ltr";var t=e.replace(/<[^>]*>/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`#]/g,"").trim();if(0===t.length)return"ltr";for(var n=/[\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,i=0,o=0,r=0,a=t;r<a.length;r++){var l=a[r];/\s|\d|[.,;:!?()[\]{}'"`\-_=+*/\\|@#$%^&*~]/.test(l)||(o++,n.test(l)&&i++)}return 0===o?"ltr":i/o>.3?"rtl":"ltr"}var Ge="https://cdn.robylon.ai/logos/WhatsApp.svg",Xe=e.memo(function(t){var n,i,o,r,a,l,s,d,u,m,g,b,w,x,E,T,I,C,A=t.config,O=t.toggleIframe,k=t.isIframeVisible,L=t.onEvent,M=t.onInternalEvent,F=t.position,B=t.sideSpacing,H=t.bottomSpacing,U=t.launcher_type,P=t.launcher_properties_text,j=t.shouldFadeIn,W=t.launcher_size,G=e.useRef(null),X=e.useState(!1),V=X[0],Y=X[1],K=e.useState(!1),J=K[0],q=K[1],Z=e.useState([]),Q=Z[0],$=Z[1],ee=e.useState(!1),te=ee[0],ne=ee[1],ie=e.useRef([]),oe=e.useRef(),re=e.useRef(new Set),ae=null!==(o=null==A?void 0:A.launcher_size_multiplier)&&void 0!==o?o:1,le=null!=W?W:48*ae,se="".concat(Math.max(4,Math.round(4*ae)),"px");e.useEffect(function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;Y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]),e.useEffect(function(){G.current&&requestAnimationFrame(function(){null==L||L({type:f.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),M(f.CHATBOT_BUTTON_LOADED)})},[L,M]),e.useEffect(function(){if(G.current&&j){G.current.style.opacity="0";var e=requestAnimationFrame(function(){G.current&&(G.current.style.opacity="1")});return function(){return cancelAnimationFrame(e)}}},[j]);var ce=F||(null===(r=A.interface_properties)||void 0===r?void 0:r.position)||"Right",de=null!==(l=null!=B?B:null===(a=A.interface_properties)||void 0===a?void 0:a.side_spacing)&&void 0!==l?l:20,ue=null!==(d=null!=H?H:null===(s=A.interface_properties)||void 0===s?void 0:s.bottom_spacing)&&void 0!==d?d:20,pe=U||(null==A?void 0:A.launcher_type)||exports.LauncherType.IMAGE,fe=P||(null===(u=null==A?void 0:A.launcher_properties)||void 0===u?void 0:u.text),me={zIndex:1e3,display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",boxSizing:"border-box"};pe===exports.LauncherType.IMAGE&&(me.width="".concat(le,"px"),me.height="".concat(le,"px"),me.borderRadius="50%",me.backgroundColor=A.brand_colour);var he=c(c({},me),((n={position:void 0,bottom:"0",borderRadius:pe===exports.LauncherType.IMAGE?"50%":"9999px"})[ce.toLowerCase()]="0",n)),ge=c(c({},me),((i={position:"fixed",bottom:"".concat(ue,"px"),borderRadius:pe===exports.LauncherType.IMAGE?"50%":"9999px"})[ce.toLowerCase()]="".concat(de,"px"),i)),ve=V?ge:he;e.useEffect(function(){v.log("Screen width changed, isMobile:",V,"Style:",ve)},[V,ve]),v.log("config in floating button",A);e.useEffect(function(){var e=function(){ie.current.forEach(function(e){return clearTimeout(e)}),ie.current=[]},t=function(){if(e(),$([]),re.current.clear(),(null==A?void 0:A.proactive_message_obj)&&!N()){var t=z(null==A?void 0:A.proactive_message_obj);p([],t,!0).sort(function(e,t){return e.delayMs!==t.delayMs?e.delayMs-t.delayMs:e.contentIndex-t.contentIndex});var n=new Map;t.forEach(function(e){var t=n.get(e.delayMs);t||(t={messageIds:[],groups:new Map},n.set(e.delayMs,t)),t.groups.has(e.messageId)||(t.messageIds.push(e.messageId),t.groups.set(e.messageId,[])),t.groups.get(e.messageId).push(e)}),n.forEach(function(e,t){var n=e.messageIds,i=e.groups,o=window.setTimeout(function(){$(function(e){var o=[];return n.forEach(function(t){(i.get(t)||[]).forEach(function(t){var n="".concat(t.messageId,"-").concat(t.contentIndex);if(!e.some(function(e){return e.id===t.messageId&&e.index===t.contentIndex})){var i={id:t.messageId,index:t.contentIndex,html:t.html,contentId:t.contentId,messageDisplayType:t.messageDisplayType,messageBubbleBg:null==t?void 0:t.messageBubbleBg,urlToGo:null==t?void 0:t.urlToGo};o.push(i),re.current.add(n),setTimeout(function(){re.current.delete(n)},1200)}})}),0===t?p(p([],e,!0),o,!0):p(p([],o,!0),e,!0)})},t);ie.current.push(o)})}};return oe.current=S(function(){q(!1),t()}),t(),function(){var t;e(),null===(t=oe.current)||void 0===t||t.call(oe)}},[null==A?void 0:A.proactive_message_obj]);var ye=Q.length>0&&!k&&!J,be="Right"===(F||(null===(m=A.interface_properties)||void 0===m?void 0:m.position)||"Right"),_e=function(){ne(!0),setTimeout(function(){q(!0),R(),ne(!1)},400)};return e.createElement(e.Fragment,null,e.createElement("style",null,"\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .proactive-bubble-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-bubble-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .proactive-bubble-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(y,';\n // font-size: inherit;\n // font-weight: inherit;\n line-height: inherit;\n color: inherit;\n text-align: inherit;\n // text-decoration: none ;\n list-style: none !important;\n }\n .proactive-message-content p,\n .proactive-message-content div,\n .proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .proactive-message-content p:first-child,\n .proactive-message-content div:first-child,\n .proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .proactive-message-content p:last-child,\n .proactive-message-content div:last-child,\n .proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .proactive-message-content b,\n .proactive-message-content strong {\n font-weight: 600 !important;\n }\n .proactive-message-content i,\n .proactive-message-content em {\n font-style: italic !important;\n }\n .proactive-message-content u {\n text-decoration: underline !important;\n }\n .proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n ')),ye?e.createElement("div",{className:"proactive-message-container",style:{position:"fixed",bottom:"".concat((null!==(b=null!=H?H:null===(g=A.interface_properties)||void 0===g?void 0:g.bottom_spacing)&&void 0!==b?b:20)+(pe===exports.LauncherType.IMAGE?le:void 0!==W?40:40*ae)+8,"px"),right:be?"".concat(null!==(x=null!=B?B:null===(w=A.interface_properties)||void 0===w?void 0:w.side_spacing)&&void 0!==x?x:20,"px"):"auto",left:be?"auto":"".concat(null!==(T=null!=B?B:null===(E=A.interface_properties)||void 0===E?void 0:E.side_spacing)&&void 0!==T?T:20,"px"),maxWidth:"22.875rem",zIndex:2147483646}},e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:be?"flex-end":"flex-start"},className:"proactive-message-bubble-container"},Q.map(function(t,n){var i="".concat(t.id,"-").concat(t.index),o=re.current.has(i),r=10*(Q.length-1-n),a=t.messageDisplayType===exports.MessageDisplayType.BUTTON;return console.log("visibleProactives",Q),e.createElement("div",{key:i,onClick:function(){if((null==t?void 0:t.urlToGo)&&"string"==typeof t.urlToGo&&""!==t.urlToGo.trim())window.open(t.urlToGo,"_blank","noopener,noreferrer");else{D({message_id:t.id,content_string:t.html||null,content_id:t.contentId||null}),O(),_e();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:t.id,content_string:t.html||null,content_id:t.contentId||null}}))}catch(e){}}},className:te?be?"proactive-bubble-exit-right":"proactive-bubble-exit-left":o&&!te?be?"proactive-bubble-enter-right":"proactive-bubble-enter-left":"",style:c({background:(null==t?void 0:t.messageBubbleBg)||"#ffffff",color:"#111",borderRadius:a?"100px":"12px",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.08)",padding:"16px",cursor:"pointer",fontFamily:y,lineHeight:_,fontSize:"14px",marginBottom:n<Q.length-1?16:0,border:"1px solid #F1F2F4",width:"fit-content",maxWidth:"100%",animationDelay:te?"0ms":o?"".concat(r,"ms"):void 0},te?{opacity:0}:o?{opacity:0,transform:be?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"}:{})},e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},e.createElement("div",{className:"proactive-message-content",dir:We(t.html),dangerouslySetInnerHTML:{__html:je(t.html)}}),(null==t?void 0:t.urlToGo)&&"string"==typeof t.urlToGo&&""!==t.urlToGo.trim()&&e.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flexShrink:0,color:h((null==t?void 0:t.messageBubbleBg)||"#ffffff")}},e.createElement("g",{id:"External_Link"},e.createElement("path",{id:"Vector",d:"M6.6668 3.83268H5.4668C4.72006 3.83268 4.34642 3.83268 4.0612 3.97801C3.81032 4.10584 3.60649 4.30966 3.47866 4.56055C3.33334 4.84576 3.33334 5.21941 3.33334 5.96615V11.0328C3.33334 11.7795 3.33334 12.1527 3.47866 12.4379C3.60649 12.6888 3.81032 12.893 4.0612 13.0208C4.34614 13.166 4.71933 13.166 5.46461 13.166H10.5354C11.2807 13.166 11.6533 13.166 11.9383 13.0208C12.1891 12.893 12.3937 12.6886 12.5215 12.4377C12.6667 12.1528 12.6667 11.78 12.6667 11.0347V9.83268M13.3333 6.49935V3.16602M13.3333 3.16602H10M13.3333 3.16602L8.66667 7.83268",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})))))})),e.createElement("div",{onClick:function(e){e.stopPropagation(),_e()},className:te?"":be?"proactive-close-enter-right":"proactive-close-enter-left",style:c({position:"absolute",top:"-32px",right:"Right"===(F||(null===(I=A.interface_properties)||void 0===I?void 0:I.position)||"Right")?"0px":"auto",left:"Left"===(F||(null===(C=A.interface_properties)||void 0===C?void 0:C.position)||"Right")?"0px":"auto",width:"24px",height:"24px",borderRadius:"50%",background:"#fff",boxShadow:" 0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",userSelect:"none",animationDelay:te?"0ms":"".concat(10*(Q.length-1),"ms")},te?{}:{opacity:0,transform:be?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)"}),"aria-label":"Close proactive message"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},e.createElement("path",{d:"M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334",stroke:"#444547",strokeWidth:"0.816326",strokeLinecap:"round",strokeLinejoin:"round"})))):null,e.createElement("div",{ref:G,className:"message-bubble-container",style:c(c({},ve),{transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",transform:k?"scale(0.85)":"scale(1)",opacity:j?0:1}),onClick:function(){O(),_e()}},function(){switch(pe){case exports.LauncherType.TEXT:return t=void 0!==W?void 0:160*ae,n=void 0!==W?void 0:40*ae,i=void 0!==W?void 0:14*ae,o=void 0!==W?void 0:21*ae,e.createElement("div",{style:{width:void 0!==t?"".concat(t,"px"):"fit-content",maxWidth:void 0!==t?"".concat(t,"px"):"160px",height:void 0!==n?"".concat(n,"px"):"40px",borderRadius:"9999px",backgroundColor:A.brand_colour,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box",fontFamily:y,lineHeight:_}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:We(fe),style:{margin:0,color:h(A.brand_colour),fontSize:void 0!==i?"".concat(i,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:y,lineHeight:void 0!==o?"".concat(o,"px"):_,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},fe)));case exports.LauncherType.TEXTUAL_IMAGE:return function(){var t,n,i,o,r=void 0!==W?void 0:174*ae,a=void 0!==W?void 0:40*ae,l=void 0!==W?void 0:40*ae,s=void 0!==W?void 0:14*ae,c=void 0!==W?void 0:21*ae,d=(null==A?void 0:A.launcher_type)?(null===(i=null===(n=null===(t=null==A?void 0:A.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||void 0===i?void 0:i.trim())||Ge:(null===(o=null==A?void 0:A.image_url)||void 0===o?void 0:o.trim())||Ge,u=d===Ge;return e.createElement("div",{style:{maxWidth:void 0!==r?"".concat(r,"px"):"13rem",width:"fit-content",height:void 0!==a?"".concat(a,"px"):"40px",borderRadius:"9999px",backgroundColor:A.brand_colour,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:0,paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box",fontFamily:y,lineHeight:_}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:We(fe),style:{margin:0,color:h(A.brand_colour),fontSize:void 0!==s?"".concat(s,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:y,lineHeight:void 0!==c?"".concat(c,"px"):_,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},fe)),e.createElement("div",{style:{width:void 0!==l?"".concat(l,"px"):"40px",height:void 0!==l?"".concat(l,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:0}},e.createElement("img",{src:d,alt:"Chat",style:{width:u?"calc(100% - 6px)":"100%",height:u?"calc(100% - 6px)":"100%",margin:u?"3px":0,borderRadius:u?0:"50%",objectFit:u?"contain":"cover",padding:u?se:0,boxSizing:"border-box"}})))}();case exports.LauncherType.IMAGE:default:return function(){var t,n,i,o;if(k){var r=Math.round(.5*le);return e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"}},e.createElement("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{display:"block"}},e.createElement("g",{id:"Chevron_Down"},e.createElement("path",{id:"Vector",d:"M19 9L12 16L5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))))}var a=(null==A?void 0:A.launcher_type)?(null===(i=null===(n=null===(t=null==A?void 0:A.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||void 0===i?void 0:i.trim())||Ge:(null===(o=null==A?void 0:A.image_url)||void 0===o?void 0:o.trim())||Ge,l=a===Ge;return e.createElement("img",{src:a,alt:"Chat",style:{zIndex:1e3,cursor:"pointer",borderRadius:l?0:"50%",objectFit:l?"contain":"cover",padding:l?se:0,width:l?"calc(100% - 3px)":"100%",height:l?"calc(100% - 3px)":"100%",margin:l?"4px":0,boxSizing:"border-box"}})}()}var t,n,i,o}()))}),Ve=function(t){var n=t.config,i=t.onCtaClick,o=(null==n?void 0:n.title_bar_color)||"#075E54",r=h(o),a=function(e){var t,n;if(null==e?void 0:e.startsWith("#")){var i=e.replace("#",""),o=3===(null==i?void 0:i.length)?null===(n=null===(t=null==i?void 0:i.split(""))||void 0===t?void 0:t.map(function(e){return"".concat(e).concat(e)}))||void 0===n?void 0:n.join(""):i;if(6===(null==o?void 0:o.length)){var r=parseInt(null==o?void 0:o.slice(0,2),16),a=parseInt(null==o?void 0:o.slice(2,4),16),l=parseInt(null==o?void 0:o.slice(4,6),16);return"rgba(".concat(r,", ").concat(a,", ").concat(l,", 0.8)")}}return"#FFFFFF"===e?"rgba(255, 255, 255, 0.8)":"rgba(14, 14, 15, 0.8)"}(r),l=(null==n?void 0:n.button_content)||"Chat on WhatsApp";return e.createElement("div",{className:"rblyn-chat-widget-popup",style:{width:"20rem",maxWidth:"calc(100vw - 20px)",borderRadius:"22px",overflow:"hidden",backgroundColor:"#fff",boxShadow:"0 16px 40px rgba(14, 14, 15, 0.2)",marginBottom:"14px"}},e.createElement("style",null,"\n .rblyn-chat-widget-popup,\n .rblyn-chat-widget-popup * {\n font-family: ".concat(b," !important;\n }\n .rblyn-chat-widget-powered-link {\n text-decoration: none;\n }\n .rblyn-chat-widget-powered-link:hover {\n text-decoration: underline;\n color: rgba(14, 14, 15, 0.8) !important;\n }\n ")),e.createElement("div",{style:{backgroundColor:o,padding:"20px 18px 16px"}},e.createElement("div",{style:{color:r,fontSize:"16px",fontWeight:600,lineHeight:"1.2"}},(null==n?void 0:n.widget_title)||"Hi there"),e.createElement("div",{style:{color:a,fontSize:"12px",marginTop:"4px"}},(null==n?void 0:n.widget_subtitle)||"We typically reply in minutes")),e.createElement("div",{style:{padding:"20px 16px 22px"}},e.createElement("button",{onClick:i,style:{width:"100%",border:"none",borderRadius:"14px",backgroundColor:(null==n?void 0:n.brand_colour)||"#25D366",color:h((null==n?void 0:n.brand_colour)||"#25D366"),fontSize:"14px",fontWeight:600,padding:"14px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"}},e.createElement("img",{src:"https://cdn.robylon.ai/logos/WhatsApp.svg",alt:"WhatsApp",style:{width:"20px",height:"20px",objectFit:"contain"}}),e.createElement("span",null,l)),(null==n?void 0:n.powered_by_robylon)?e.createElement("div",{style:{textAlign:"center",color:"rgba(14, 14, 15, 0.4)",fontSize:"14px",marginTop:"14px"}},"Powered by"," ",e.createElement("a",{href:"https://www.robylon.ai",target:"_blank",rel:"noopener noreferrer",className:"rblyn-chat-widget-powered-link"},"Robylon")):null))},Ye=function(){var e;return(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platform)||(/Windows|Mac|Linux|Android|iOS/.exec(navigator.userAgent)||["Unknown"])[0]},Ke=function(){var e;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands)for(var t=["Chrome","Firefox","Safari","Edge","Opera"],n=0,i=navigator.userAgentData.brands;n<i.length;n++){var o=i[n];if(t.includes(o.brand))return o.brand}return(/Chrome|Firefox|Safari|Edge|Opera/.exec(navigator.userAgent)||["Unknown"])[0]},Je=function(){var e,t,n,i;return{width:(null===window||void 0===window?void 0:window.innerWidth)||(null===(e=null===document||void 0===document?void 0:document.documentElement)||void 0===e?void 0:e.clientWidth)||(null===(t=null===document||void 0===document?void 0:document.body)||void 0===t?void 0:t.clientWidth),height:(null===window||void 0===window?void 0:window.innerHeight)||(null===(n=null===document||void 0===document?void 0:document.documentElement)||void 0===n?void 0:n.clientHeight)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.clientHeight)}},qe=function(){return{platform:"web",os:Ye(),browser:Ke(),sdk_version:"1.0.2",device:(e=navigator.userAgent.toLowerCase(),/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"),screen_size:Je()};var e};v.log("Raw API_URL:","https://api.robylon.ai");var Ze={copilotUrl:"https://chatbot.robylon.ai",environment:"production",apiUrl:"https://api.robylon.ai"};v.log("CONFIG",Ze);var Qe,$e=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},et=function(){return{copilotUrl:Ze.copilotUrl||"https://app.robylon.ai",environment:Ze.environment||"production",apiUrl:Ze.apiUrl||"https://app.robylon.ai"}};!function(e){e.ERROR="ERROR",e.INFO="INFO"}(Qe||(Qe={}));var tt,nt=["@robylon/whatsapp-react-sdk","node_modules/@robylon/whatsapp-react-sdk/"],it=function(e){var t=e.filename,n=e.stack,i=e.message;return!!(t||n||i)&&nt.some(function(e){return(null==t?void 0:t.includes(e))||(null==n?void 0:n.includes(e))||(null==i?void 0:i.includes(e))})},ot=function(){function e(){var e=this;this.apiKey="",this.userId=null,this.preInitQueue=[],this.isInitialized=!1,this.handleWindowError=function(t){var n,i={filename:t.filename,stack:null===(n=t.error)||void 0===n?void 0:n.stack,message:t.message};it(i)&&e.trackError(t.error||t.message,"GlobalErrorHandler",{filename:t.filename,lineNo:t.lineno,colNo:t.colno})},this.handleUnhandledRejection=function(t){var n,i,o={stack:null===(n=t.reason)||void 0===n?void 0:n.stack,message:(null===(i=t.reason)||void 0===i?void 0:i.message)||String(t.reason)};it(o)&&e.trackError(t.reason||"Unhandled Promise Rejection","GlobalPromiseHandler",{reason:t.reason})},this.setupGlobalHandlers()}return e.prototype.setupGlobalHandlers=function(){$e()&&(null===window||void 0===window||window.addEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.addEventListener("unhandledrejection",this.handleUnhandledRejection))},e.prototype.cleanup=function(){$e()&&(null===window||void 0===window||window.removeEventListener("error",null==this?void 0:this.handleWindowError),null===window||void 0===window||window.removeEventListener("unhandledrejection",this.handleUnhandledRejection))},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.initialize=function(e,t){void 0===t&&(t=null);try{if(this.preInitQueue.length>0){var n={org_id:"UNINITALIZED",event_data:{message:"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e)),componentName:"ErrorTrackingService",additionalInfo:{preInitError:!0,apiKey:e,userId:t,timestamp:Date.now()},timestamp:Date.now()},metadata:qe(),event_type:Qe.ERROR,user_id:t};this.sendLog(n).catch(console.error)}this.apiKey=e,this.userId=t,this.isInitialized=!0,this.processPreInitQueue()}catch(n){v.error("Error during ErrorTrackingService initialization:",n),this.preInitQueue.push({error:n instanceof Error?n:new Error(String(n)),componentName:"ErrorTrackingService",additionalInfo:{apiKey:e,userId:t}})}},e.prototype.processPreInitQueue=function(){return d(this,void 0,void 0,function(){var e,t,n;return u(this,function(i){switch(i.label){case 0:if(!this.preInitQueue.length)return[2];v.info("Processing ".concat(this.preInitQueue.length," pre-initialization errors")),e=0,t=this.preInitQueue,i.label=1;case 1:return e<t.length?(n=t[e],[4,this.trackError(n.error,n.componentName,c(c({},n.additionalInfo),{preInitError:!0}))]):[3,4];case 2:i.sent(),i.label=3;case 3:return e++,[3,1];case 4:return this.preInitQueue=[],[2]}})})},e.prototype.sendLog=function(e){return d(this,void 0,void 0,function(){var t,n,i,o,r,a;return u(this,function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),t=et().apiUrl,[4,fetch("".concat(t,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return(n=l.sent()).ok?[3,3]:(o=(i=v).error,r=["Failed to send error log:"],[4,n.text()]);case 2:o.apply(i,r.concat([l.sent()])),l.label=3;case 3:return[3,5];case 4:return a=l.sent(),v.error("Error sending log:",a),[3,5];case 5:return[2]}})})},e.prototype.trackError=function(e,t,n){return d(this,void 0,void 0,function(){var i,o,r;return u(this,function(a){switch(a.label){case 0:if(this.isInitialized)return[3,5];i={org_id:"UNINITALIZED",event_data:{message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:c(c({},n),{preInitError:!0,timestamp:Date.now()}),timestamp:Date.now()},metadata:qe(),event_type:Qe.ERROR,user_id:this.userId},a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.sendLog(i)];case 2:return a.sent(),[3,4];case 3:return a.sent(),this.preInitQueue.push({error:e,componentName:t,additionalInfo:n}),v.warn("Error tracked before initialization, queuing:",e),[3,4];case 4:return[2];case 5:return o={message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:t,additionalInfo:c(c({},n),{timestamp:Date.now()}),timestamp:Date.now()},r={org_id:this.apiKey||"UNINITALIZED",event_data:o,metadata:qe(),event_type:Qe.ERROR,user_id:this.userId},[4,this.sendLog(r)];case 6:return a.sent(),[2]}})})},e.prototype.trackInfo=function(e,t,n){return d(this,void 0,void 0,function(){var i,o;return u(this,function(r){switch(r.label){case 0:return this.apiKey?(i={message:e,componentName:t,additionalInfo:n,timestamp:Date.now()},o={org_id:this.apiKey,event_data:i,metadata:qe(),event_type:Qe.INFO,user_id:this.userId},[4,this.sendLog(o)]):(v.error("Error tracking not initialized"),[2]);case 1:return r.sent(),[2]}})})},e}(),rt=ot.getInstance(),at="MISSING_API_KEY",lt="INVALID_API_KEY",st="CONFIG_FETCH_FAILED",ct="SDK_INIT_FAILED",dt="ERROR_TRACKING_INIT_FAILED",ut="API_REQUEST_FAILED",pt="NETWORK_ERROR",ft="INVALID_RESPONSE",mt="IFRAME_LOAD_FAILED",ht="COOKIE_ACCESS_ERROR",gt="COMPONENT_RENDER_ERROR",vt="INITIALIZATION_ERROR",yt="API_ERROR",bt="COMPONENT_ERROR",_t=((tt={})[at]=function(e){return"SDK Initialization Failed: Required parameter 'api_key' is ".concat(void 0===e?"undefined":null===e?"null":""===e?"empty string":"invalid: ".concat(e),". A valid API key string is required to initialize the SDK.")},tt[lt]=function(e){return"SDK Initialization Failed: Provided API key '".concat(e,"' is invalid. API key must be a non-empty string in UUID format.")},tt[st]=function(e){return"Failed to fetch chatbot configuration: ".concat(e.statusCode?"Server responded with status ".concat(e.statusCode):"Could not reach server").concat(e.error?". Error: ".concat(e.error):"")},tt[ut]=function(e,t,n){return"API Request Failed: Server responded with status ".concat(e," for ").concat(n?"endpoint ".concat(n):"request"," - ").concat(t)},tt[pt]=function(e){return"Network Error: Failed to communicate with server".concat(e.url?" at ".concat(e.url):"").concat(e.error?" - ".concat(e.error):"")},tt[mt]=function(e){return"Failed to load chatbot interface".concat(e.src?" from ".concat(e.src):"").concat(e.error?". Error: ".concat(e.error):"")},tt[ft]=function(e){return"Invalid API Response: Missing required fields in response data: ".concat(e.join(", "))},tt[dt]=function(e){return"Error Tracking Service initialization failed".concat(e.apiKey?" for API key ".concat(e.apiKey):"").concat(e.error?". Error: ".concat(e.error):"")},tt[ct]=function(e){return"SDK Initialization Failed: ".concat(e.reason||"Could not initialize the chatbot SDK").concat(e.config?". Attempted initialization with config: ".concat(JSON.stringify(e.config,null,2)):"")},tt[ht]=function(e,t){return"Cookie Access Error: Failed to ".concat(e).concat(t?" cookie '".concat(t,"'"):" cookies",". This may affect user session persistence.")},tt[gt]=function(e){return"React Component Error: ".concat(e.component||"Unknown component"," failed to render. Error: ").concat(e.error).concat(e.stack?"\nComponent Stack: ".concat(e.stack):"")},tt),wt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={hasError:!1},t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(n,e),n.getDerivedStateFromError=function(e){return{hasError:!0}},n.prototype.componentDidCatch=function(e,t){rt.trackError(new Error(_t[gt]({component:this.props.componentName||void 0,error:e.message,stack:t.componentStack})),this.props.componentName||void 0,{errorCode:gt,errorType:bt,context:{originalError:e,componentStack:t.componentStack,timestamp:Date.now()}})},n.prototype.render=function(){return this.state.hasError?null:this.props.children},n}(e.Component),xt=function(e){var t=e?"USER_DATA=%7B%22attributes%22%3A%5B%7B%22key%22%3A%22USER_ATTRIBUTE_USER_EMAIL%22%2C%22value%22%3A%22dinesh.goel%40robylon.ai%22%7D%2C%7B%22key%22%3A%22USER_ATTRIBUTE_UNIQUE_ID%22%2C%22value%22%3A%2266011f2c28d1787d13c6c796%22%7D%5D%2C%22subscribedToOldSdk%22%3Afalse%2C%22deviceUuid%22%3A%2226c02feb-2664-451d-8469-9cf1378547c6%22%2C%22deviceAdded%22%3Atrue%7D; _ga_3YS9P6ZDWX=GS1.1.1715252584.3.1.1715258696.39.0.0; _ga_V4J24F7YF9=GS1.1.1715273274.2.0.1715273274.0.0.0; city_name=Bengaluru; lang_code=en-in; cookieConcent=A; _gcl_au=1.1.343275043.1717154298; _clck=43guwd%7C2%7Cfmi%7C0%7C1561; _gid=GA1.2.1423066649.1718210058; moe_uuid=26c02feb-2664-451d-8469-9cf1378547c6; _ga_6RM65PWEZY=GS1.1.1718210058.18.1.1718211647.60.0.0; _ga=GA1.1.689213983.1712737672; AMP_MKTG_fe4beb374f=JTdCJTIycmVmZXJyZXIlMjIlM0ElMjJodHRwcyUzQSUyRiUyRmFjY291bnRzLnRlYWNobWludC5jb20lMkYlMjIlMkMlMjJyZWZlcnJpbmdfZG9tYWluJTIyJTNBJTIyYWNjb3VudHMudGVhY2htaW50LmNvbSUyMiU3RA==; AMP_fe4beb374f=JTdCJTIyZGV2aWNlSWQlMjIlM0ElMjI0MWMxMTljZC03YzVjLTRiYTctYTUzZS1mYTgzMjRlYjc0OWUlMjIlMkMlMjJ1c2VySWQlMjIlM0ElMjIxZjI2ODAwOC01OGYxLTQwYTItYjQ0Ni1mYmQ5N2E0NDQyYTAlMjIlMkMlMjJzZXNzaW9uSWQlMjIlM0ExNzE4MjEzMzEwOTc3JTJDJTIyb3B0T3V0JTIyJTNBZmFsc2UlMkMlMjJsYXN0RXZlbnRUaW1lJTIyJTNBMTcxODIxMzMxMDk4MSUyQyUyMmxhc3RFdmVudElkJTIyJTNBMTQlN0Q=; _ga_3YS9P6ZDWX=GS1.1.1718211637.26.1.1718213441.60.0.0; SESSION=%7B%22sessionKey%22%3A%22e4d76f52-9053-4277-99a4-f1ba667fd5f2%22%2C%22sessionStartTime%22%3A%222024-06-12T16%3A34%3A19.047Z%22%2C%22sessionMaxTime%22%3A1800%2C%22customIdentifiersToTrack%22%3A%5B%5D%2C%22sessionExpiryTime%22%3A1718215247464%2C%22numberOfSessions%22%3A17%7D":document.cookie;return t=t.split(";").map(function(e){var t=e.split("="),n=t[0],i=t.slice(1).join("=").trim();return{name:n=n.trim(),value:i?decodeURIComponent(i):""}}),t},Et=function(){var e,t=navigator.userAgent;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands){var n=navigator.userAgentData.brands.find(function(e){return"Google Chrome"===e.brand});if(null==n?void 0:n.version)return n.version}var i=t.match(/(Chrome|Firefox|Safari|Edge|Opera)\/(\d+\.\d+)/);return i?i[2]:"Unknown"},Tt=function(){var e,t,n=qe();return{current_page_url:(null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.href)||"",browser_language:(null===navigator||void 0===navigator?void 0:navigator.language)||(null===(t=null===navigator||void 0===navigator?void 0:navigator.languages)||void 0===t?void 0:t[0])||"en",browser_version:Et(),os:null==n?void 0:n.os,referral_url:(null===document||void 0===document?void 0:document.referrer)||"",system_info:n}},It="https://cdn.robylon.ai/logos/WhatsApp.svg",Ct=function(){function e(e){this.logoContainer=null,this.iframe=null,this.bubblePromptContainer=null,this.chatBtnImage=null,this.config=e,this.validateDomain()&&this.init(),null===window||void 0===window||window.addEventListener("message",this.onCloseListener.bind(this),!1)}return e.prototype.onCloseListener=function(e){e.origin===this.config.domain&&"closeChatbot"===e.data&&this.closeIframe()},e.prototype.validateDomain=function(){var e,t=this.config.domain,n=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.origin;return v.log("expectedDomain, to current domain",t,n,t===n),t===n},e.prototype.createChatBubblContainer=function(){var e,t=this,n=document.createElement("div");n.id="chatbase-message-bubbles",Object.assign(n.style,{position:"fixed",bottom:"80px",borderRadius:"10px",fontFamily:"sans-serif",fontSize:"16px",zIndex:"2147483644",cursor:"pointer",flexDirection:"column",gap:"50px",maxWidth:"70vw",display:"block",right:"1rem",left:"unset"});var i=document.createElement("div");i.classList.add("close-btn"),i.textContent="✕",Object.assign(i.style,{position:"absolute",top:"-7px",right:"-7px",fontWeight:"bold",display:"none",justifyContent:"center",alignItems:"center",zIndex:"2147483643",width:"22px",height:"22px",borderRadius:"50%",textAlign:"center",fontSize:"12px",cursor:"pointer",backgroundColor:"rgb(224, 224, 224)",color:"black",boxShadow:"rgba(150, 150, 150, 0.15) 0px 6px 24px 0px, rgba(150, 150, 150, 0.15) 0px 0px 0px 1px"}),((null===(e=this.config.chat_interface_config)||void 0===e?void 0:e.chat_bubble_prompts)||[]).forEach(function(e){var i=t.createMessageBubble(e);n.appendChild(i)}),n.appendChild(i),document.body.appendChild(n)},e.prototype.createMessageBubble=function(e){var t=document.createElement("div");this.bubblePromptContainer=t,Object.assign(t.style,{display:"flex",position:"relative",justifyContent:"flex-end"});var n=document.createElement("div");n.classList.add("message"),n.textContent=e,Object.assign(n.style,{backgroundColor:"white",color:"black",boxShadow:"rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px",borderRadius:"10px",padding:"8px 5px",margin:"8px",fontSize:"14px",opacity:"1",transform:"scale(1)",transition:"opacity 0.5s ease 0s, transform 0.5s ease 0s"});var i=document.createElement("button");return i.innerHTML="×",Object.assign(i.style,{position:"absolute",top:"1px",left:"-3px",width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#fff",color:"#000",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 5px rgba(0,0,0,0.2)",fontSize:"14px",lineHeight:"1",padding:"0",zIndex:"100"}),i.addEventListener("click",function(){t.remove()}),t.appendChild(i),t.appendChild(n),t},e.prototype.createFloatingButton=function(){var e=document.createElement("div");e.classList.add("message-bubble-container"),Object.assign(e.style,{position:"fixed",bottom:"1.5rem",right:"1.5rem",zIndex:"1000",width:"48px",height:"48px",display:"flex",flexDirection:"column-reverse",backgroundColor:this.config.brand_colour,color:h(this.config.brand_colour),borderRadius:"50%",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden"}),document.body.appendChild(e),this.logoContainer=e,this.loadImage(this.logoContainer),this.createChatBubblContainer(),this.logoContainer.addEventListener("click",this.toggleIframe.bind(this))},e.prototype.loadImage=function(e){var t,n,i,o,r,a,l,s,c,d=document.createElement("img"),u=null!==(n=null===(t=this.config)||void 0===t?void 0:t.launcher_size_multiplier)&&void 0!==n?n:1,p="".concat(Math.max(4,Math.round(4*u)),"px"),f=(null===(i=this.config)||void 0===i?void 0:i.launcher_type)?(null===(l=null===(a=null===(r=null===(o=this.config)||void 0===o?void 0:o.images)||void 0===r?void 0:r.launcher_image_url)||void 0===a?void 0:a.url)||void 0===l?void 0:l.trim())||It:(null===(c=null===(s=this.config)||void 0===s?void 0:s.image_url)||void 0===c?void 0:c.trim())||It,m=f===It;d.src=f,d.alt="Chat",Object.assign(d.style,{zIndex:"1000",cursor:"pointer",borderRadius:m?"0":"50%",objectFit:m?"contain":"cover",padding:m?p:"0",boxSizing:"border-box",width:m?"calc(100% - 3px)":"100%",height:m?"calc(100% - 3px)":"100%",margin:m?"4px":"0"}),this.chatBtnImage=d,e.innerHTML="",e.appendChild(d)},e.prototype.createIframe=function(){var e=this;v.log("RobylonConfig?.domain====>",this.config.domain);var t=document.createElement("iframe");Object.assign(t.style,{position:"fixed",right:"32px",bottom:"86px",minWidth:"400px",width:"26%",maxWidth:"800px",top:"calc(10vh - 32px)",maxHeight:"45rem",height:"calc(100vh - 3rem - 10vh)",zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom right",transition:"transform 0.3s ease-out",borderRadius:"1rem",display:"none"}),t.src="".concat(this.config.domain,"/chatbot-plugin?id=").concat(this.config.chatbotId),v.log("iframe.src====>",t.src),document.body.appendChild(t),this.iframe=t;var n=function(){(null===window||void 0===window?void 0:window.innerWidth)<560?Object.assign(t.style,{width:"100vw",minWidth:"300px",right:"0",bottom:"0",height:"100vh",flexDirection:"column",flexGrow:"1",borderRadius:"0",top:"0",maxHeight:"100%"}):Object.assign(t.style,{width:"26%",minWidth:"400px",right:"32px",bottom:"86px",height:"calc(100vh - 3rem - 10vh)",borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"45rem"})};n(),null===window||void 0===window||window.addEventListener("resize",n),t.addEventListener("load",function(){var n,i,o,r,a;if(e.iframe){var l=new URL(e.iframe.src).origin||e.config.domain;null===(n=t.contentWindow)||void 0===n||n.postMessage({domain:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname,name:"checkDomain"},l),null===(o=t.contentWindow)||void 0===o||o.postMessage({domain:null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hostname,action:"registerUserId",data:{userId:e.config.userId,token:e.config.token,userProfile:c(c({},e.config.userProfile||{}),{__INT_SYS_INFO__:c(c({},(null===(a=e.config.userProfile)||void 0===a?void 0:a.__INT_SYS_INFO__)||{}),Tt())})}},l)}}),null===window||void 0===window||window.addEventListener("message",function(n){var i,o;if(n.origin===e.config.domain){if("captureSessionData"===n.data){var r="66b33d16-5b38-4693-8772-1a1bd7dd412d"===e.config.chatbotId,a={cookies:xt(r),localStorage:JSON.stringify(localStorage),sessionStorage:JSON.stringify(sessionStorage),action:"capturedSessionData",domain_name:null===(i=null===window||void 0===window?void 0:window.location)||void 0===i?void 0:i.hostname};null===(o=t.contentWindow)||void 0===o||o.postMessage(a,e.config.domain||"*")}"expand"===n.data&&(e.adjustIframeWidth(),t.style.height="calc(100vh - 120px)",t.style.bottom="86px"),"collapse"===n.data&&Object.assign(t.style,{width:"26%",height:"calc(100vh - 32px - 10vh)",bottom:"86px",top:"calc(32px + 10vh)"})}})},e.prototype.adjustIframeWidth=function(){if(this.iframe){var e=null===window||void 0===window?void 0:window.innerWidth;v.log("screenWidth",e),this.iframe.style.width=e<832?"".concat(e-64,"px"):"800px"}},e.prototype.loadSvgInline=function(e){var t=document.createElement("div");t.innerHTML='\n<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g id="Chevron_Down">\n <path id="Vector" d="M19 9L12 16L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>\n </g>\n</svg>\n';var n=t.querySelector("svg");e.innerHTML="",n&&e.appendChild(n)},e.prototype.toggleIcon=function(e,t){"block"===t.style.display?this.loadSvgInline(e):this.loadImage(e)},e.prototype.toggleIframe=function(){var e,t;if(v.log("toggleIframe",this.iframe,this.logoContainer,this.chatBtnImage),this.iframe&&this.logoContainer&&this.chatBtnImage){var n=new URL(this.iframe.src).origin||this.config.domain;v.log("toggleIframe"),null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage({domain:null===window||void 0===window?void 0:window.location.hostname,name:"none"===this.iframe.style.display?"openFrame":"closeFrame"},n),this.iframe.style.display="none"===this.iframe.style.display?"block":"none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="block"===this.iframe.style.display?"none":(null===(t=this.chatBtnImage)||void 0===t?void 0:t.src)===It?"contain":"cover",this.bubblePromptContainer&&(this.bubblePromptContainer.style.display="none"),v.log("this.bubblePromptContainer",this.bubblePromptContainer)}},e.prototype.closeIframe=function(){var e;this.iframe&&this.logoContainer&&this.chatBtnImage&&(this.iframe.style.display="none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit=(null===(e=this.chatBtnImage)||void 0===e?void 0:e.src)===It?"contain":"cover")},e.prototype.init=function(){this.createIframe(),this.createFloatingButton()},e}(),St=function(e,t,n){if(e.chatbotId&&e.userId)try{new Ct(e);t(!0),v.log("Robylon SDK initialized successfully.")}catch(e){n(e instanceof Error?e.message:"Failed to initialize SDK")}else n("Incomplete configuration for SDK initialization.")},At=function(e){return function(e){var t,n,i,o,r,a,l,s;return Boolean((null===(i=null===(n=null===(t=null==e?void 0:e.user)||void 0===t?void 0:t.org_info)||void 0===n?void 0:n.brand_config)||void 0===i?void 0:i.widget)&&(null===(s=null===(l=null===(a=null===(r=null===(o=null==e?void 0:e.user)||void 0===o?void 0:o.org_info)||void 0===r?void 0:r.brand_config)||void 0===a?void 0:a.profile)||void 0===l?void 0:l.qr_code)||void 0===s?void 0:s.chat_link))}(e)?function(e){var t,n,i=null===(n=null===(t=null==e?void 0:e.user)||void 0===t?void 0:t.org_info)||void 0===n?void 0:n.brand_config;return{profile:null==i?void 0:i.profile,widget:null==i?void 0:i.widget,business_profile:null==i?void 0:i.business_profile,display_name:null==i?void 0:i.display_name}}(e):e},Ot=function(e,t,n){return d(void 0,void 0,void 0,function(){var i,o,r,a,l,s,c,d,p,f;return u(this,function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),i=et().apiUrl,o="".concat(i,"/chat/whatsapp/get/"),v.log("endpointUrl",o),r={client_user_id:t||null,org_id:e,token:n||void 0,extra_info:{},launcher_info:Tt(),phone_no_id:"739739745898120"},[4,fetch(o,{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify(r)})];case 1:return(a=u.sent()).ok?[3,3]:[4,a.text()];case 2:throw l=u.sent(),new Error(_t[ut](a.status,l));case 3:return[4,a.json()];case 4:if(s=u.sent(),c=At(s),!(null===(f=null===(p=null==c?void 0:c.profile)||void 0===p?void 0:p.qr_code)||void 0===f?void 0:f.chat_link)||!(null==c?void 0:c.widget))throw new Error(_t[ft](["profile","widget"]));return[2,c];case 5:throw d=u.sent(),rt.trackError(d instanceof Error?d:new Error(_t[pt]({error:String(d)})),"fetchChatbotConfig",{errorCode:d instanceof Error&&d.message.includes("API Request Failed")?ut:pt,errorType:yt,context:{apiKey:e,userId:t,timestamp:Date.now()}}),d;case 6:return[2]}})})},kt=function(e){return d(void 0,void 0,void 0,function(){var t,n,i,o,r,a,l,s,d,p,f,m,h,g,y,b,_,w,x,E,T,I,C,S,A,O,k,R,N,D,L,M,z;return u(this,function(u){switch(u.label){case 0:return t=function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(e),n=t.user_id||void 0,i=!1,n||(n=function(e){var t,n="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===n.length)return null===(t=n.pop())||void 0===t?void 0:t.split(";").shift()}("rblyn_anon")||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),B="rblyn_anon",H=n,U=365,(P=new Date).setTime(P.getTime()+24*U*60*60*1e3),document.cookie="".concat(B,"=").concat(H,";expires=").concat(P.toUTCString(),";path=/"),i=!0),[4,Ot(t.api_key,n,t.user_token)];case 1:o=u.sent();try{t.api_key}catch(e){v.warn("Failed to inject mock proactive messages",e)}return r=qe(),a=Tt(),F=t.user_profile,l=F?Object.fromEntries(Object.entries(F).map(function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]})):{},s=c(c(c({},r),{__INT_SYS_INFO__:c(c({},r),a)}),l),d=function(e){if("string"==typeof e)return(null==e?void 0:e.trim())||"";var t=null==e?void 0:e.url;return"string"==typeof t&&(null==t?void 0:t.trim())||""}(null===(p=null==o?void 0:o.widget)||void 0===p?void 0:p.launcher_image),[2,{chatbotId:t.api_key,userId:n,token:t.user_token,isAnonymous:i,domain:"",show_launcher:!0,brand_colour:(null===(f=null==o?void 0:o.widget)||void 0===f?void 0:f.brand_color)||"#25D366",image_url:d,userProfile:s,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(m=null==o?void 0:o.widget)||void 0===m?void 0:m.title)||(null==o?void 0:o.display_name)||"",welcome_message:(null===(h=null==o?void 0:o.widget)||void 0===h?void 0:h.subtitle)||"Hey! What can we help you with today?",redirect_url:(null===(y=null===(g=null==o?void 0:o.profile)||void 0===g?void 0:g.qr_code)||void 0===y?void 0:y.chat_link)||""},launcher_type:(null===(b=null==o?void 0:o.widget)||void 0===b?void 0:b.launcher_type)||exports.LauncherType.IMAGE,launcher_properties:{text:(null===(_=null==o?void 0:o.widget)||void 0===_?void 0:_.launcher_text)||(null===(w=null==o?void 0:o.widget)||void 0===w?void 0:w.button_content)||""},images:{launcher_image_url:{url:d}},proactive_message_obj:void 0,interface_properties:{position:(null===(x=null==o?void 0:o.widget)||void 0===x?void 0:x.position)||exports.WidgetPositionEnums.RIGHT,side_spacing:(null===(E=null==o?void 0:o.widget)||void 0===E?void 0:E.side_spacing)||20,bottom_spacing:(null===(T=null==o?void 0:o.widget)||void 0===T?void 0:T.bottom_spacing)||20},interface_type:exports.ChatbotInterfaceType.WIDGET,launcher_delay:{enabled:!1,delay:0},launcher_size_multiplier:null!==(C=null===(I=null==o?void 0:o.widget)||void 0===I?void 0:I.launcher_size_multiplier)&&void 0!==C?C:1,redirect_chat_link:(null===(A=null===(S=null==o?void 0:o.profile)||void 0===S?void 0:S.qr_code)||void 0===A?void 0:A.chat_link)||"",pre_filled_message:(null===(k=null===(O=null==o?void 0:o.profile)||void 0===O?void 0:O.qr_code)||void 0===k?void 0:k.pre_filled_message)||"",widget_type:(null===(R=null==o?void 0:o.widget)||void 0===R?void 0:R.widget_type)||"quick_launch",widget_title:(null===(N=null==o?void 0:o.widget)||void 0===N?void 0:N.title)||"",widget_subtitle:(null===(D=null==o?void 0:o.widget)||void 0===D?void 0:D.subtitle)||"",title_bar_color:(null===(L=null==o?void 0:o.widget)||void 0===L?void 0:L.title_bar_color)||"#075E54",button_content:(null===(M=null==o?void 0:o.widget)||void 0===M?void 0:M.button_content)||"Chat on WhatsApp",powered_by_robylon:!1!==(null===(z=null==o?void 0:o.widget)||void 0===z?void 0:z.powered_by_robylon)}]}var F,B,H,U,P})})},Rt=function(t){var n=e.useMemo(function(){return function(e){return{api_key:String(e.api_key||""),user_id:e.user_id?String(e.user_id):null,user_token:e.user_token?String(e.user_token):void 0,user_profile:e.user_profile||{}}}(t)},[t.api_key,t.user_id,t.user_token,JSON.stringify(t.user_profile)]),i=e.useState({isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1}),o=i[0],r=i[1],a=e.useMemo(function(){return n.user_profile?Object.fromEntries(Object.entries(n.user_profile).map(function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]})):{}},[JSON.stringify(n.user_profile)]),l=e.useCallback(function(e){r(function(t){return c(c({},t),e)})},[]),s=e.useCallback(function(){return d(void 0,void 0,void 0,function(){var e,t,i,o;return u(this,function(r){switch(r.label){case 0:if(!n.api_key)return rt.trackError(new Error(_t[at](n.api_key)),"useChatbotState",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}}),[2];l({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,kt(n)];case 2:return e=r.sent(),t=c(c(c({},qe()),null==e?void 0:e.userProfile),a),e.userProfile=t,[4,new Promise(function(t,n){St(e,function(){l({isInitialized:!0,chatbotConfig:e}),t()},function(e){n(e)})})];case 3:return r.sent(),[3,6];case 4:return i=r.sent(),o=i instanceof Error?i.message:"Failed to initialize chatbot",l({error:o}),rt.trackError(i instanceof Error?i:new Error(o),"useChatbotState",{errorCode:ct,errorType:vt,context:{timestamp:Date.now()}}),[3,6];case 5:return l({isInitializing:!1}),[7];case 6:return[2]}})})},[n.api_key,n.user_id,n.user_token]);e.useEffect(function(){n.api_key&&s()},[s]),e.useEffect(function(){o.chatbotConfig&&r(function(e){return c(c({},e),{chatbotConfig:c(c({},e.chatbotConfig),{userProfile:c(c({},qe()),a)})})})},[a]);var p=e.useCallback(function(){r(function(e){return c(c({},e),{isIframeVisible:!e.isIframeVisible})})},[]),f=e.useCallback(function(){l({isIframeVisible:!1})},[]);return c(c({},o),{toggleIframeVisibility:p,closeIframe:f})},Nt=function(t){var n,i,o,r,a,l,s,d=t.children,u=t.config,p=t.position,f=t.sideSpacing,m=t.bottomSpacing,h=e.useState(!1),g=h[0],y=h[1];e.useEffect(function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;y(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);var b=p||(null===(o=u.interface_properties)||void 0===o?void 0:o.position)||"Right",_=null!==(a=null!=f?f:null===(r=u.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,w=null!==(s=null!=m?m:null===(l=u.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==s?s:20;v.log("config",u,b,_);var x={position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column"},E=c(c({},x),((n={bottom:"".concat(w,"px")})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),n.alignItems="Right"===b?"flex-end":"flex-start",n.top=void 0,n["Right"===b?"left":"right"]=void 0,n)),T=c(c({},x),((i={top:0})[b.toLowerCase()]="".concat(null!=_?_:20,"px"),i.alignItems="center",i.bottom=void 0,i["Right"===b?"left":"right"]=void 0,i)),I=g?T:E;return e.useEffect(function(){console.log("Container screen width changed, isMobile:",g,"Style:",I)},[g,I]),e.createElement("div",{className:"robylon-chatbot-container",style:I},d)},Dt=e.forwardRef(function(t,n){var i,o,r,a=t.api_key,l=t.user_id,s=t.user_token,m=t.user_profile,h=t.onEvent,g=t.position,y=t.sideSpacing,b=t.bottomSpacing,_=t.show_launcher,w=t.launcher_type,x=t.launcher_properties_text;t.overrides;var E=t.launcher_size,T="string"==typeof y?""===y||isNaN(Number(y))?void 0:Number(y):y,I="string"==typeof b?""===b||isNaN(Number(b))?void 0:Number(b):b,C="string"==typeof g?"left"===g.toLowerCase()?"Left":"right"===g.toLowerCase()?"Right":void 0:g;e.useEffect(function(){});var S=e.useMemo(function(){return{api_key:a,user_id:l,user_token:s,user_profile:m}},[a,l,s,m]),A=e.useCallback(function(e){null==h||h(e)},[h]),O=Rt(S),k=O.isInitialized,R=O.error,N=O.chatbotConfig,D=O.isIframeVisible,L=O.toggleIframeVisibility,M=O.closeIframe,z=e.useMemo(function(){return{api_key:a,user_profile:S.user_profile,onEvent:A,chatbotConfig:N?{isAnonymous:N.isAnonymous,userId:N.userId}:null}},[a,S.user_profile,A,null==N?void 0:N.isAnonymous,null==N?void 0:N.userId]),F=function(t){var n=t.api_key,i=t.chatbotConfig,o=t.user_profile,r=t.onEvent,a=e.useMemo(function(){return{isAnonymous:(null==i?void 0:i.isAnonymous)||!1,userId:(null==i?void 0:i.userId)||""}},[null==i?void 0:i.isAnonymous,null==i?void 0:i.userId]),l=e.useMemo(function(){return o||{}},[JSON.stringify(o)]),s=e.useCallback(function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return d(void 0,p([e],t,!0),void 0,function(e,t){var i,o,r,s,d,p,f;return void 0===t&&(t={}),u(this,function(u){switch(u.label){case 0:if(!n)return[2];u.label=1;case 1:return u.trys.push([1,3,,4]),i=et().apiUrl,o=qe(),r=c({trigger_time:Date.now(),channel:"CHATBOT",launch_url:(null===(f=null===window||void 0===window?void 0:window.location)||void 0===f?void 0:f.href)||"",org_id:n,client_user_id:a.isAnonymous?"Anonymous":String(a.userId),event_type:e,user_profile:l},t),s={org_id:n,event_data:r,metadata:c({timestamp:Date.now()},o),event_type:"INFO",user_id:a.userId},[4,fetch("".concat(i,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})];case 2:if(!(d=u.sent()).ok)throw new Error("Failed to send internal event: ".concat(d.statusText));return[3,4];case 3:return p=u.sent(),v.error("Failed to send internal event:",p),[3,4];case 4:return[2]}})})},[n,a]);return{emitEvent:e.useCallback(function(e,t){var n=Date.now();e!==f.CHATBOT_BUTTON_CLICKED&&e!==f.CHATBOT_CLOSED&&e!==f.CHATBOT_OPENED&&e!==f.CHATBOT_READY||(r&&r({type:e,timestamp:n,data:t}),s(e,{timestamp:n}))},[r,s]),onInternalEvent:s}}(c({},z)),B=F.emitEvent,H=F.onInternalEvent;e.useImperativeHandle(n,function(){return{show:function(){k&&N?"chat_widget"===(null==N?void 0:N.widget_type)?D||(L(),B(f.CHATBOT_BUTTON_CLICKED)):(null==N?void 0:N.redirect_chat_link)&&(window.open(null==N?void 0:N.redirect_chat_link,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot show - chatbot not ready yet")},hide:function(){k&&N?"chat_widget"===(null==N?void 0:N.widget_type)&&D&&(M(),B(f.CHATBOT_CLOSED)):console.warn("Robylon Chatbot: Cannot hide - chatbot not ready yet")},toggle:function(){k&&N?"chat_widget"===(null==N?void 0:N.widget_type)?(L(),B(D?f.CHATBOT_CLOSED:f.CHATBOT_BUTTON_CLICKED)):(null==N?void 0:N.redirect_chat_link)&&(window.open(null==N?void 0:N.redirect_chat_link,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot toggle - chatbot not ready yet")},isReady:k&&!!N}},[k,N,D,L,M,B]),e.useEffect(function(){k&&N&&B(f.CHATBOT_READY)},[k,N,B]);var U=e.useState(!1),P=U[0],j=U[1];e.useEffect(function(){var e,t,n,i,o,r,a;if(!(void 0!==_?Boolean(_):null===(e=null==N?void 0:N.show_launcher)||void 0===e||e))return j(!1),function(){a&&clearTimeout(a)};var l=!0===(null===(t=null==N?void 0:N.launcher_delay)||void 0===t?void 0:t.enabled),s=null!==(r=null!==(i=null===(n=null==N?void 0:N.launcher_delay)||void 0===n?void 0:n.seconds)&&void 0!==i?i:null===(o=null==N?void 0:N.launcher_delay)||void 0===o?void 0:o.delay)&&void 0!==r?r:0;return l&&Number(s)>0?(j(!1),a=window.setTimeout(function(){j(!0)},1e3*Number(s))):j(!0),function(){a&&clearTimeout(a)}},[_,null==N?void 0:N.show_launcher,null===(i=null==N?void 0:N.launcher_delay)||void 0===i?void 0:i.enabled,null===(o=null==N?void 0:N.launcher_delay)||void 0===o?void 0:o.seconds,null===(r=null==N?void 0:N.launcher_delay)||void 0===r?void 0:r.delay]),e.useEffect(function(){if(a)try{rt.initialize(a,l)}catch(e){rt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:dt,errorType:vt,context:{timestamp:Date.now()}})}else rt.trackError(new Error(_t[at](a)),"RobylonChatbot",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}})},[a,l]);var W="chat_widget"===(null==N?void 0:N.widget_type),G=e.useCallback(function(){var e=null==N?void 0:N.redirect_chat_link;W?(L(),B(D?f.CHATBOT_CLOSED:f.CHATBOT_BUTTON_CLICKED)):e&&(window.open(e,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED))},[null==N?void 0:N.redirect_chat_link,B,W,D,L]),X=e.useCallback(function(){var e=null==N?void 0:N.redirect_chat_link;e&&(window.open(e,"_blank","noopener,noreferrer"),B(f.CHATBOT_BUTTON_CLICKED)),M()},[null==N?void 0:N.redirect_chat_link,B,M]),V=e.useMemo(function(){var e,t,n,i,o;return{config:N,toggleIframe:G,isIframeVisible:D,onEvent:A,onInternalEvent:H,position:C,sideSpacing:T,bottomSpacing:I,launcher_type:w,launcher_properties_text:x,shouldFadeIn:!0===(null===(e=null==N?void 0:N.launcher_delay)||void 0===e?void 0:e.enabled)&&(null!==(o=null!==(n=null===(t=null==N?void 0:N.launcher_delay)||void 0===t?void 0:t.seconds)&&void 0!==n?n:null===(i=null==N?void 0:N.launcher_delay)||void 0===i?void 0:i.delay)&&void 0!==o?o:0)>0||!1,launcher_size:E}},[N,G,D,A,H,C,T,I,w,x,E]);return v.log("floatingButtonProps",V),a&&!R&&N?e.createElement(wt,{componentName:"RobylonChatbot"},k?e.createElement(Nt,{config:N,position:C,sideSpacing:T,bottomSpacing:I},W&&D?e.createElement(wt,{componentName:"ChatWidgetPopup"},e.createElement(Ve,{config:N,onCtaClick:X})):null,e.createElement(wt,{componentName:"ChatbotFloatingButton"},P?e.createElement(Xe,c({},V)):null)):null):null}),Lt=e.memo(Dt,function(e,t){return e.api_key===t.api_key&&e.user_id===t.user_id&&e.user_token===t.user_token&&JSON.stringify(e.user_profile)===JSON.stringify(t.user_profile)&&e.position===t.position&&e.sideSpacing===t.sideSpacing&&e.bottomSpacing===t.bottomSpacing&&e.show_launcher===t.show_launcher&&e.launcher_type===t.launcher_type&&e.launcher_properties_text===t.launcher_properties_text&&JSON.stringify(e.overrides)===JSON.stringify(t.overrides)&&e.launcher_size===t.launcher_size&&!0}),Mt="https://cdn.robylon.ai/logos/WhatsApp.svg",zt=function(){function e(e){var t=this;this.resizeObserver=null,this.proactiveElement=null,this.urlUnsubscribe=null,this.delayTimers=[],this.config=e,this.buttonElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.render(),this.mount();try{this.buttonElement.style.opacity="0",this.buttonElement.style.transition="transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",requestAnimationFrame(function(){t.buttonElement.style.opacity="1"})}catch(e){}this.setupResizeListener(),this.renderProactiveIfNeeded(),this.urlUnsubscribe=S(function(){t.clearProactiveDelays(),t.renderProactiveIfNeeded(!0)})}return e.prototype.render=function(){var e,t,n=this,i=this.config,o=i.config,r=i.isIframeVisible,a=null!==(e=null==o?void 0:o.launcher_size_multiplier)&&void 0!==e?e:1,l=null!==(t=this.config.launcher_size)&&void 0!==t?t:48*a,s={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97)",transform:r?"scale(0.85)":"scale(1)",fontFamily:y};o.launcher_type===exports.LauncherType.IMAGE&&Object.assign(s,{width:"".concat(l,"px"),height:"".concat(l,"px"),borderRadius:"50%",backgroundColor:o.brand_colour}),this.applyResponsiveStyles(s),this.buttonElement.className="message-bubble-container",this.buttonElement.innerHTML="",this.buttonElement.appendChild(this.createLauncherElement()),this.buttonElement.onclick=function(){n.config.toggleIframe(),n.hideProactiveMessages()},this.renderProactiveIfNeeded()},e.prototype.createLauncherElement=function(){var e,t,n,i,o,r,a=this.config,l=a.config,s=a.isIframeVisible,c=null!==(e=null==l?void 0:l.launcher_size_multiplier)&&void 0!==e?e:1,d=null!==(t=this.config.launcher_size)&&void 0!==t?t:48*c,u="".concat(Math.max(4,Math.round(4*c)),"px"),p=(null==l?void 0:l.launcher_type)?(null===(o=null===(i=null===(n=null==l?void 0:l.images)||void 0===n?void 0:n.launcher_image_url)||void 0===i?void 0:i.url)||void 0===o?void 0:o.trim())||Mt:(null===(r=null==l?void 0:l.image_url)||void 0===r?void 0:r.trim())||Mt,f=p===Mt;switch(console.log("config in floating button",l),l.launcher_type){case exports.LauncherType.TEXT:return this.createTextLauncher();case exports.LauncherType.TEXTUAL_IMAGE:return this.createTextualImageLauncher();case exports.LauncherType.IMAGE:default:if(s){var m=Math.round(.5*d),h=document.createElement("div");Object.assign(h.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"});var g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("width",String(m)),g.setAttribute("height",String(m)),g.setAttribute("viewBox","0 0 24 24"),g.setAttribute("fill","none"),g.setAttribute("xmlns","http://www.w3.org/2000/svg"),g.style.display="block";var v=document.createElementNS("http://www.w3.org/2000/svg","path");return v.setAttribute("d","M19 9L12 16L5 9"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),v.setAttribute("stroke-linecap","round"),v.setAttribute("stroke-linejoin","round"),g.appendChild(v),h.appendChild(g),h}var y=document.createElement("img");return y.src=p,y.alt="Chat",Object.assign(y.style,{zIndex:"1000",cursor:"pointer",borderRadius:f?"0":"50%",objectFit:f?"contain":"cover",padding:f?u:"0",width:f?"calc(100% - 3px)":"100%",height:f?"calc(100% - 3px)":"100%",margin:f?"4px":"0",boxSizing:"border-box"}),y}},e.prototype.createTextLauncher=function(){var e=this.config.config,t=e.brand_colour,n=e.launcher_properties,i=e.launcher_size_multiplier,o=null!=i?i:1,r=void 0!==this.config.launcher_size?void 0:160*o,a=void 0!==this.config.launcher_size?void 0:40*o,l=void 0!==this.config.launcher_size?void 0:14*o,s=void 0!==this.config.launcher_size?void 0:21*o,c=document.createElement("div");Object.assign(c.style,{width:void 0!==r?"".concat(r,"px"):"fit-content",maxWidth:void 0!==r?"".concat(r,"px"):"160px",height:void 0!==a?"".concat(a,"px"):"40px",borderRadius:"9999px",backgroundColor:t,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box"});var d=document.createElement("div");Object.assign(d.style,{flex:"1",minWidth:"0"});var u=document.createElement("p");return Object.assign(u.style,{margin:"0",color:h(t),fontSize:void 0!==l?"".concat(l,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==s?"".concat(s,"px"):_,fontFamily:y,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),u.textContent=(null==n?void 0:n.text)||"",d.appendChild(u),c.appendChild(d),c},e.prototype.createTextualImageLauncher=function(){var e,t,n,i,o,r,a,l=this.config.config,s=l.brand_colour,c=l.launcher_properties,d=l.image_url,u=l.launcher_size_multiplier,p=(null===(t=null===(e=null==this?void 0:this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.launcher_type)?(null===(a=null===(r=null===(o=null===(i=null===(n=null==this?void 0:this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.images)||void 0===o?void 0:o.launcher_image_url)||void 0===r?void 0:r.url)||void 0===a?void 0:a.trim())||Mt:(null==d?void 0:d.trim())||Mt,f=p===Mt,m=null!=u?u:1,g="".concat(Math.max(4,Math.round(4*m)),"px"),v=void 0!==this.config.launcher_size?void 0:174*m,b=void 0!==this.config.launcher_size?void 0:40*m,w=void 0!==this.config.launcher_size?void 0:40*m,x=void 0!==this.config.launcher_size?void 0:14*m,E=void 0!==this.config.launcher_size?void 0:21*m,T=document.createElement("div");Object.assign(T.style,{maxWidth:void 0!==v?"".concat(v,"px"):"13rem",width:"fit-content",height:void 0!==b?"".concat(b,"px"):"40px",borderRadius:"9999px",backgroundColor:s,display:"flex",alignItems:"center",paddingLeft:"20px",paddingRight:"0",paddingTop:"9px",paddingBottom:"9px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",gap:"8px",boxSizing:"border-box"});var I=document.createElement("div");Object.assign(I.style,{flex:"1",minWidth:"0"});var C=document.createElement("p");Object.assign(C.style,{margin:"0",color:h(s),fontSize:void 0!==x?"".concat(x,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==E?"".concat(E,"px"):_,fontFamily:y,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),C.textContent=(null==c?void 0:c.text)||"";var S=document.createElement("div");Object.assign(S.style,{width:void 0!==w?"".concat(w,"px"):"40px",height:void 0!==w?"".concat(w,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:"0"});var A=document.createElement("img");return A.src=p,A.alt="Chat",Object.assign(A.style,{width:f?"calc(100% - 6px)":"100%",height:f?"calc(100% - 6px)":"100%",margin:f?"3px":"0",borderRadius:f?"0":"50%",objectFit:f?"contain":"cover",padding:f?g:"0",boxSizing:"border-box"}),I.appendChild(C),S.appendChild(A),T.appendChild(I),T.appendChild(S),T},e.prototype.applyResponsiveStyles=function(e){var t,n,i,o,r,a,l,s,d,u=(null===window||void 0===window?void 0:window.innerWidth)<560,p=this.config.config,f=this.config.position||(null===(i=p.interface_properties)||void 0===i?void 0:i.position)||"Right",m=null!==(a=null!==(o=this.config.sideSpacing)&&void 0!==o?o:null===(r=p.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,h=null!==(d=null!==(l=this.config.bottomSpacing)&&void 0!==l?l:null===(s=p.interface_properties)||void 0===s?void 0:s.bottom_spacing)&&void 0!==d?d:20;this.buttonElement.style.position="",this.buttonElement.style.bottom="",this.buttonElement.style.right="",this.buttonElement.style.left="";var g=c(c({},e),u?((t={position:"fixed",bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),t):((n={bottom:"".concat(h,"px")})[f.toLowerCase()]="".concat(m,"px"),n));Object.assign(this.buttonElement.style,g)},e.prototype.handleResize=function(){var e,t,n,i=null!==(t=null===(e=this.config.config)||void 0===e?void 0:e.launcher_size_multiplier)&&void 0!==t?t:1,o=null!==(n=this.config.launcher_size)&&void 0!==n?n:48*i,r={zIndex:"1000",display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",borderRadius:this.config.config.launcher_type&&this.config.config.launcher_type!==exports.LauncherType.IMAGE?"9999px":"50%",boxSizing:"border-box"};this.config.config.launcher_type===exports.LauncherType.IMAGE&&Object.assign(r,{width:"".concat(o,"px"),height:"".concat(o,"px"),borderRadius:"50%",backgroundColor:this.config.config.brand_colour}),this.applyResponsiveStyles(r)},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.getElement=function(){return this.buttonElement},e.prototype.mount=function(){var e=this;requestAnimationFrame(function(){var t,n;null===(n=(t=e.config).onEvent)||void 0===n||n.call(t,{type:f.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),e.config.onInternalEvent(f.CHATBOT_BUTTON_LOADED)})},e.prototype.update=function(e){this.config.isIframeVisible,this.config=c(c({},this.config),e),this.buttonElement.style.transform=this.config.isIframeVisible?"scale(0.85)":"scale(1)",this.render(),this.renderProactiveIfNeeded()},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.buttonElement&&this.buttonElement.parentNode&&this.buttonElement.parentNode.removeChild(this.buttonElement),this.proactiveElement&&this.proactiveElement.parentElement&&(this.proactiveElement.parentElement.removeChild(this.proactiveElement),this.proactiveElement=null),this.clearProactiveDelays(),this.urlUnsubscribe&&(this.urlUnsubscribe(),this.urlUnsubscribe=null)},e.prototype.clearProactiveDelays=function(){this.delayTimers.forEach(function(e){return clearTimeout(e)}),this.delayTimers=[]},e.prototype.hideProactiveMessages=function(){var e,t,n=this;R();var i=null===(e=this.proactiveElement)||void 0===e?void 0:e.children[0];if(i){var o="Right"===(this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right");Array.from(i.children).forEach(function(e){e.className=o?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"}),setTimeout(function(){n.proactiveElement&&n.proactiveElement.parentElement&&n.proactiveElement.parentElement.removeChild(n.proactiveElement),n.proactiveElement=null,n.clearProactiveDelays()},400)}else this.clearProactiveDelays()},e.prototype.injectAnimationStyles=function(){if(!document.getElementById("rblyn-proactive-animations")){var e=document.createElement("style");e.id="rblyn-proactive-animations",e.textContent="\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(-1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideInFromLeft {\n 0% {\n transform: translateX(-120%) scale(0.95);\n opacity: 0;\n }\n 85% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 92% {\n transform: translateX(1px) scale(1.002);\n }\n 100% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n }\n @keyframes slideOutRight {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(120%) scale(0.9);\n opacity: 0;\n }\n }\n @keyframes slideOutLeft {\n 0% {\n transform: translateX(0) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateX(-120%) scale(0.9);\n opacity: 0;\n }\n }\n .rblyn-proactive-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-exit-right {\n animation: slideOutRight 0.4s ease-in forwards;\n }\n .rblyn-proactive-exit-left {\n animation: slideOutLeft 0.4s ease-in forwards;\n }\n .rblyn-proactive-close-enter-right {\n animation: slideInFromRight 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n .rblyn-proactive-close-enter-left {\n animation: slideInFromLeft 1.2s cubic-bezier(0.5, 0.8, 0.3, 1.1) forwards;\n }\n /* Reset styles for proactive message content to prevent website CSS interference */\n /* Only target children of the content wrapper, not the bubble container itself */\n .rblyn-proactive-message-content * {\n box-sizing: border-box !important;\n margin: 0 !important;\n padding: 0 !important;\n border: none !important;\n background: transparent;\n font-family: ".concat(y,' !important;\n font-size: inherit !important;\n font-weight: inherit !important;\n line-height: inherit !important;\n color: inherit;\n text-align: inherit;\n list-style: none;\n }\n .rblyn-proactive-message-content p,\n .rblyn-proactive-message-content div,\n .rblyn-proactive-message-content span {\n display: inline !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n .rblyn-proactive-message-content p:first-child,\n .rblyn-proactive-message-content div:first-child,\n .rblyn-proactive-message-content span:first-child {\n margin-top: 0 !important;\n }\n .rblyn-proactive-message-content p:last-child,\n .rblyn-proactive-message-content div:last-child,\n .rblyn-proactive-message-content span:last-child {\n margin-bottom: 0 !important;\n }\n .rblyn-proactive-message-content a {\n color: inherit !important;\n text-decoration: underline !important;\n cursor: pointer !important;\n }\n .rblyn-proactive-message-content a:hover {\n opacity: 0.8 !important;\n }\n .rblyn-proactive-message-content b,\n .rblyn-proactive-message-content strong {\n font-weight: 600 !important;\n }\n .rblyn-proactive-message-content i,\n .rblyn-proactive-message-content em {\n font-style: italic !important;\n }\n .rblyn-proactive-message-content u {\n text-decoration: underline !important;\n }\n .rblyn-proactive-message-content br {\n display: block !important;\n content: "" !important;\n margin-top: 0.5em !important;\n }\n '),document.head.appendChild(e)}},e.prototype.renderProactiveIfNeeded=function(e){var t,n,i,o,r,a,l,s,c,d,u,f,m,g,v,b=this,w=null===(n=null===(t=this.config)||void 0===t?void 0:t.config)||void 0===n?void 0:n.proactive_message_obj;if(Array.isArray(w)&&!this.config.isIframeVisible&&!N()){if(this.injectAnimationStyles(),!this.proactiveElement){var x=document.createElement("div");x.style.position="fixed";var E=null!==(a=null!==(o=this.config.bottomSpacing)&&void 0!==o?o:null===(r=this.config.config.interface_properties)||void 0===r?void 0:r.bottom_spacing)&&void 0!==a?a:20,T=null!==(c=null!==(l=this.config.sideSpacing)&&void 0!==l?l:null===(s=this.config.config.interface_properties)||void 0===s?void 0:s.side_spacing)&&void 0!==c?c:20,I=this.config.position||(null===(d=this.config.config.interface_properties)||void 0===d?void 0:d.position)||"Right",C=null!==(f=null===(u=this.config.config)||void 0===u?void 0:u.launcher_size_multiplier)&&void 0!==f?f:1,S=null!==(m=this.config.launcher_size)&&void 0!==m?m:48*C,A=this.config.config.launcher_type===exports.LauncherType.IMAGE?S:void 0!==this.config.launcher_size?40:40*C;x.style.bottom="".concat(E+A+8,"px"),"Right"===I?x.style.right="".concat(T,"px"):x.style.left="".concat(T,"px"),x.style.maxWidth="22.875rem",x.style.zIndex="2147483646";var O=document.createElement("div");O.style.display="flex",O.style.flexDirection="column",O.style.alignItems="Right"===I?"flex-end":"flex-start";var k=document.createElement("div");k.style.position="absolute",k.style.top="-32px",k.style.width="24px",k.style.height="24px",k.style.borderRadius="50%",k.style.background="#fff",k.style.boxShadow="0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",k.style.display="flex",k.style.alignItems="center",k.style.justifyContent="center",k.style.cursor="pointer",k.style.opacity="0",k.style.visibility="hidden","Right"===(this.config.position||(null===(g=this.config.config.interface_properties)||void 0===g?void 0:g.position)||"Right")?(k.style.right="0px",k.style.left="auto",k.style.transform="translateX(120%) scale(0.95)"):(k.style.left="0px",k.style.right="auto",k.style.transform="translateX(-120%) scale(0.95)"),k.onclick=function(e){e.stopPropagation(),b.hideProactiveMessages()},k.innerHTML='\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">\n <path d="M10.3334 10.3334L7.00009 7.00009M7.00009 7.00009L3.66675 3.66675M7.00009 7.00009L10.3334 3.66675M7.00009 7.00009L3.66675 10.3334" stroke="#444547" stroke-width="0.816326" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n ',x.appendChild(O),x.appendChild(k),document.body.appendChild(x),this.proactiveElement=x}var R=this.proactiveElement.children[0];R.innerHTML="";var L="Right"===(this.config.position||(null===(v=this.config.config.interface_properties)||void 0===v?void 0:v.position)||"Right");R.style.display="flex",R.style.flexDirection="column",R.style.alignItems=L?"flex-end":"flex-start",this.clearProactiveDelays();var M=z(w);p([],M,!0).sort(function(e,t){return e.delayMs!==t.delayMs?e.delayMs-t.delayMs:e.contentIndex-t.contentIndex});var F=new Map;M.forEach(function(e){var t=F.get(e.delayMs);t||(t={messageIds:[],groups:new Map},F.set(e.delayMs,t)),t.groups.has(e.messageId)||(t.messageIds.push(e.messageId),t.groups.set(e.messageId,[])),t.groups.get(e.messageId).push(e)});var B=void 0!==F.get(0),H=this.proactiveElement.children[1];if(H&&M.length>0){H.style.opacity="0",H.style.visibility="hidden",H.style.transform=L?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var U=function(){if(H){H.style.visibility="visible";var e=R.children.length,t=e>0?10*(e-1):0;H.style.animationDelay="".concat(t,"ms"),H.className=L?"rblyn-proactive-close-enter-right":"rblyn-proactive-close-enter-left"}};if(B){var P=window.setTimeout(U,0);this.delayTimers.push(P)}else{var j=Math.min.apply(Math,Array.from(F.keys()));P=window.setTimeout(U,j);this.delayTimers.push(P)}}else H&&(H.style.opacity="0",H.style.visibility="hidden");var W=0;F.forEach(function(e,t){var n=e.messageIds,i=e.groups,o=window.setTimeout(function(){var e=R.children.length,o=0,r=[];n.forEach(function(e){var t=i.get(e)||[];p([],t,!0).sort(function(e,t){return e.contentIndex-t.contentIndex}).forEach(function(t){r.push({messageId:e,item:t})}),o+=t.length});var a=t>0?p([],r,!0).reverse():r;a.forEach(function(n,i){var r,l=n.item,s=document.createElement("div"),c=l.messageDisplayType===exports.MessageDisplayType.BUTTON;s.style.background=(null==l?void 0:l.messageBubbleBg)||"#ffffff",s.style.color="#111",s.style.borderRadius=c?"100px":"12px",s.style.boxShadow="0 2px 2px 0 rgba(0, 0, 0, 0.08)",s.style.padding="16px",s.style.border="1px solid #F1F2F4",s.style.cursor="pointer",s.style.fontFamily=y,s.style.fontSize="14px",s.style.lineHeight=String(_),s.style.width="fit-content",s.style.maxWidth="100%";var d=0===i,u=i===a.length-1,p=e>0,f=F.has(0),m=!1;0===t?m=!u||d&&p:d&&(p||f)?m=!0:d||(m=!0),m&&(s.style.marginBottom="16px");var g=10*(e+o-1-(0===t?e+W:W));s.className=L?"rblyn-proactive-enter-right":"rblyn-proactive-enter-left",s.style.animationDelay="".concat(g,"ms"),s.style.opacity="0",s.style.transform=L?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var v=document.createElement("div");Object.assign(v.style,{display:"flex",alignItems:"center",gap:"8px"});var w=document.createElement("div");if(w.className="rblyn-proactive-message-content",w.setAttribute("dir",We(l.html)),w.innerHTML=je(l.html),v.appendChild(w),(null==l?void 0:l.urlToGo)&&"string"==typeof l.urlToGo&&""!==l.urlToGo.trim()){var x=document.createElementNS("http://www.w3.org/2000/svg","svg");x.setAttribute("width","16"),x.setAttribute("height","17"),x.setAttribute("viewBox","0 0 16 17"),x.setAttribute("fill","none"),x.setAttribute("xmlns","http://www.w3.org/2000/svg"),Object.assign(x.style,{flexShrink:"0",color:h((null==l?void 0:l.messageBubbleBg)||"#ffffff")});var E=document.createElementNS("http://www.w3.org/2000/svg","g");E.setAttribute("id","External_Link");var T=document.createElementNS("http://www.w3.org/2000/svg","path");T.setAttribute("id","Vector"),T.setAttribute("d","M6.6668 3.83268H5.4668C4.72006 3.83268 4.34642 3.83268 4.0612 3.97801C3.81032 4.10584 3.60649 4.30966 3.47866 4.56055C3.33334 4.84576 3.33334 5.21941 3.33334 5.96615V11.0328C3.33334 11.7795 3.33334 12.1527 3.47866 12.4379C3.60649 12.6888 3.81032 12.893 4.0612 13.0208C4.34614 13.166 4.71933 13.166 5.46461 13.166H10.5354C11.2807 13.166 11.6533 13.166 11.9383 13.0208C12.1891 12.893 12.3937 12.6886 12.5215 12.4377C12.6667 12.1528 12.6667 11.78 12.6667 11.0347V9.83268M13.3333 6.49935V3.16602M13.3333 3.16602H10M13.3333 3.16602L8.66667 7.83268"),T.setAttribute("stroke","currentColor"),T.setAttribute("stroke-width","1.5"),T.setAttribute("stroke-linecap","round"),T.setAttribute("stroke-linejoin","round"),E.appendChild(T),x.appendChild(E),v.appendChild(x)}if(s.appendChild(v),s.onclick=function(){if((null==l?void 0:l.urlToGo)&&"string"==typeof l.urlToGo&&""!==l.urlToGo.trim())window.open(l.urlToGo,"_blank","noopener,noreferrer");else{D({message_id:l.messageId,content_string:l.html||null,content_id:l.contentId||null}),b.config.toggleIframe(),b.hideProactiveMessages();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:l.messageId,content_string:l.html||null,content_id:l.contentId||null}}))}catch(e){}}},0===t)R.appendChild(s);else{R.insertBefore(s,R.firstChild);var I=null===(r=b.proactiveElement)||void 0===r?void 0:r.children[1];if(I&&"visible"===I.style.visibility){var C=R.children.length,S=C>0?10*(C-1):0;I.style.animationDelay="".concat(S,"ms")}}W++})},t);b.delayTimers.push(o)})}else if(this.proactiveElement&&this.proactiveElement.parentElement){var G=this.proactiveElement.children[0],X="Right"===(this.config.position||(null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.position)||"Right");Array.from(G.children).forEach(function(e){e.className=X?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"}),setTimeout(function(){b.proactiveElement&&b.proactiveElement.parentElement&&b.proactiveElement.parentElement.removeChild(b.proactiveElement),b.proactiveElement=null,b.clearProactiveDelays()},400)}else this.proactiveElement=null,this.clearProactiveDelays()},e}(),Ft=function(){function e(e,t,n,i){this.resizeObserver=null,this.containerElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.config={config:e,position:t,sideSpacing:n,bottomSpacing:i},this.render(),this.mount(),this.setupResizeListener()}return e.prototype.render=function(){this.applyStyles(),this.containerElement.className="robylon-chatbot-container"},e.prototype.applyStyles=function(){var e,t,n,i,o,r,a,l,s,d=(null===window||void 0===window?void 0:window.innerWidth)<560,u=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",p=null!==(r=null!==(i=this.config.sideSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.side_spacing)&&void 0!==r?r:20,f=null!==(s=null!==(a=this.config.bottomSpacing)&&void 0!==a?a:null===(l=this.config.config.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==s?s:20;this.containerElement.style.position="",this.containerElement.style.top="",this.containerElement.style.bottom="",this.containerElement.style.right="",this.containerElement.style.left="",this.containerElement.style.alignItems="";var m={position:"fixed",zIndex:"1000",display:"flex",flexDirection:"column"},h=c(c({},m),((e={bottom:"".concat(f,"px")})[u.toLowerCase()]="".concat(p,"px"),e.alignItems="Right"===u?"flex-end":"flex-start",e)),g=c(c({},m),((t={top:"0"})[u.toLowerCase()]="".concat(p,"px"),t.alignItems="center",t));Object.assign(this.containerElement.style,d?g:h)},e.prototype.handleResize=function(){this.applyStyles()},e.prototype.setupResizeListener=function(){"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(this.handleResizeFunction),this.resizeObserver.observe(document.body)):window.addEventListener("resize",this.handleResizeFunction)},e.prototype.mount=function(){document.body.appendChild(this.containerElement)},e.prototype.getElement=function(){return this.containerElement},e.prototype.destroy=function(){this.resizeObserver?(this.resizeObserver.disconnect(),this.resizeObserver=null):window.removeEventListener("resize",this.handleResizeFunction),this.containerElement&&this.containerElement.parentNode&&this.containerElement.parentNode.removeChild(this.containerElement)},e}(),Bt=function(){function e(e){this.config=e,this.popupElement=document.createElement("div"),this.render()}return e.prototype.createTitleBar=function(){var e,t,n,i,o,r,a=(null===(t=null===(e=this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.title_bar_color)||"#075E54",l=h(a),s=function(e){var t,n;if(null==e?void 0:e.startsWith("#")){var i=e.replace("#",""),o=3===(null==i?void 0:i.length)?null===(n=null===(t=null==i?void 0:i.split(""))||void 0===t?void 0:t.map(function(e){return"".concat(e).concat(e)}))||void 0===n?void 0:n.join(""):i;if(6===(null==o?void 0:o.length)){var r=parseInt(null==o?void 0:o.slice(0,2),16),a=parseInt(null==o?void 0:o.slice(2,4),16),l=parseInt(null==o?void 0:o.slice(4,6),16);return"rgba(".concat(r,", ").concat(a,", ").concat(l,", 0.8)")}}return"#FFFFFF"===e?"rgba(255, 255, 255, 0.8)":"rgba(14, 14, 15, 0.8)"}(l),c=document.createElement("div");Object.assign(c.style,{backgroundColor:a,padding:"16px 18px 14px"});var d=document.createElement("div");d.textContent=(null===(i=null===(n=this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.widget_title)||"Hi there",Object.assign(d.style,{color:l,fontSize:"16px",fontWeight:"600",lineHeight:"1.2"});var u=document.createElement("div");return u.textContent=(null===(r=null===(o=this.config)||void 0===o?void 0:o.config)||void 0===r?void 0:r.widget_subtitle)||"We typically reply in minutes",Object.assign(u.style,{color:s,fontSize:"12px",marginTop:"4px"}),c.appendChild(d),c.appendChild(u),c},e.prototype.createContent=function(){var e,t,n,i,o,r,a,l,s=document.createElement("div");Object.assign(s.style,{padding:"20px 16px 16px"});var c=document.createElement("button");Object.assign(c.style,{width:"100%",border:"none",borderRadius:"14px",backgroundColor:(null===(t=null===(e=this.config)||void 0===e?void 0:e.config)||void 0===t?void 0:t.brand_colour)||"#25D366",color:h((null===(i=null===(n=this.config)||void 0===n?void 0:n.config)||void 0===i?void 0:i.brand_colour)||"#25D366"),fontSize:"14px",fontWeight:"600",padding:"10px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",letterSpacing:"0.01em"});var d=document.createElement("img");d.src="https://cdn.robylon.ai/logos/WhatsApp.svg",d.alt="WhatsApp",Object.assign(d.style,{width:"20px",height:"20px",objectFit:"contain"});var u=document.createElement("span");if(u.textContent=(null===(r=null===(o=this.config)||void 0===o?void 0:o.config)||void 0===r?void 0:r.button_content)||"Chat on WhatsApp",c.appendChild(d),c.appendChild(u),c.onclick=this.config.onCtaClick,s.appendChild(c),null===(l=null===(a=this.config)||void 0===a?void 0:a.config)||void 0===l?void 0:l.powered_by_robylon){var p=document.createElement("div");Object.assign(p.style,{textAlign:"center",color:"rgba(14, 14, 15, 0.4)",fontSize:"10px",marginTop:"10px"}),p.appendChild(document.createTextNode("Powered by "));var f=document.createElement("a");f.href="https://www.robylon.ai",f.target="_blank",f.rel="noopener noreferrer",f.textContent="Robylon",Object.assign(f.style,{color:"inherit",textDecoration:"none"}),f.addEventListener("mouseenter",function(){f.style.textDecoration="underline",f.style.color="rgba(14, 14, 15, 0.8)"}),f.addEventListener("mouseleave",function(){f.style.textDecoration="none",f.style.color="inherit"}),p.appendChild(f),s.appendChild(p)}return s},e.prototype.render=function(){this.popupElement.innerHTML="",this.popupElement.className="rblyn-chat-widget-popup",Object.assign(this.popupElement.style,{width:"19rem",maxWidth:"calc(100vw - 19rem)",borderRadius:"22px",overflow:"hidden",backgroundColor:"#fff",boxShadow:"0 16px 40px rgba(14, 14, 15, 0.2)",marginBottom:"14px"});var e=document.createElement("style");e.textContent="\n .rblyn-chat-widget-popup,\n .rblyn-chat-widget-popup * {\n font-family: ".concat(b," !important;\n }\n "),this.popupElement.appendChild(e),this.popupElement.appendChild(this.createTitleBar()),this.popupElement.appendChild(this.createContent())},e.prototype.getElement=function(){return this.popupElement},e.prototype.update=function(e){this.config=e,this.render()},e.prototype.destroy=function(){var e;(null===(e=this.popupElement)||void 0===e?void 0:e.parentNode)&&this.popupElement.parentNode.removeChild(this.popupElement)},e}(),Ht=function(e){e.api_key,e.user_profile;var t=e.onEvent;e.chatbotConfig;return{emit:function(e,n){var i={type:e,timestamp:Date.now(),data:n};null==t||t(i)},onInternalEvent:function(e,t){}}},Ut=function(){function e(e){var t=this;this.container=null,this.floatingButton=null,this.launcherDelayTimeout=null,this.popup=null,this.isDestroyed=!1,this.handleStateChange=function(e){var n,i,o,r,a,l,s,c;if(!t.isDestroyed){var d=e.isInitialized,u=e.error,p=e.chatbotConfig,f=e.isIframeVisible,m="chat_widget"===(null==p?void 0:p.widget_type);if(!u&&p&&d){t.eventEmitter=Ht({api_key:t.config.api_key,user_profile:t.config.user_profile,onEvent:t.config.onEvent,chatbotConfig:{isAnonymous:p.isAnonymous,userId:p.userId}}),t.container||(t.container=new Ft(p,t.config.position,t.config.sideSpacing,t.config.bottomSpacing)),m&&f?t.popup?t.popup.update({config:p,onCtaClick:t.handlePopupCta}):(t.popup=new Bt({config:p,onCtaClick:t.handlePopupCta}),null===(i=null===(n=t.container)||void 0===n?void 0:n.getElement())||void 0===i||i.prepend(t.popup.getElement())):t.popup&&(t.popup.destroy(),t.popup=null);var h=void 0!==t.config.show_launcher?Boolean(t.config.show_launcher):null===(o=null==p?void 0:p.show_launcher)||void 0===o||o,g=!0===(null===(r=null==p?void 0:p.launcher_delay)||void 0===r?void 0:r.enabled),v=null!==(c=null!==(l=null===(a=null==p?void 0:p.launcher_delay)||void 0===a?void 0:a.seconds)&&void 0!==l?l:null===(s=null==p?void 0:p.launcher_delay)||void 0===s?void 0:s.delay)&&void 0!==c?c:0,y=function(){if(t.floatingButton)t.floatingButton.update({config:p,isIframeVisible:f,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing,launcher_size:t.config.launcher_size});else if(t.floatingButton=new zt({config:p,toggleIframe:t.toggleIframe,isIframeVisible:f,onEvent:t.config.onEvent,onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing,launcher_size:t.config.launcher_size}),t.floatingButton.getElement&&"function"==typeof t.floatingButton.getElement){var e=t.floatingButton.getElement();e&&t.container&&t.container.getElement().appendChild(e)}};t.launcherDelayTimeout&&(clearTimeout(t.launcherDelayTimeout),t.launcherDelayTimeout=null),h?g&&Number(v)>0&&!t.floatingButton?t.launcherDelayTimeout=window.setTimeout(function(){y(),t.launcherDelayTimeout=null},1e3*Number(v)):y():t.floatingButton&&(t.floatingButton.destroy(),t.floatingButton=null)}}},this.toggleIframe=function(){var e,n,i=t.stateManager.getState(),o=null===(e=null==i?void 0:i.chatbotConfig)||void 0===e?void 0:e.redirect_chat_link;"chat_widget"===(null===(n=null==i?void 0:i.chatbotConfig)||void 0===n?void 0:n.widget_type)?(t.stateManager.toggleIframeVisibility(),t.eventEmitter.emit(i.isIframeVisible?f.CHATBOT_CLOSED:f.CHATBOT_BUTTON_CLICKED)):o&&(window.open(o,"_blank","noopener,noreferrer"),t.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED))},this.handlePopupCta=function(){var e,n=t.stateManager.getState(),i=null===(e=null==n?void 0:n.chatbotConfig)||void 0===e?void 0:e.redirect_chat_link;i&&(window.open(i,"_blank","noopener,noreferrer"),t.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED)),t.stateManager.closeIframe()};var n=c(c({},e),{position:"string"==typeof e.position?"left"===e.position.toLowerCase()?"Left":"right"===e.position.toLowerCase()?"Right":void 0:void 0,sideSpacing:"string"==typeof e.sideSpacing?""===e.sideSpacing||isNaN(Number(e.sideSpacing))?void 0:Number(e.sideSpacing):e.sideSpacing,bottomSpacing:"string"==typeof e.bottomSpacing?""===e.bottomSpacing||isNaN(Number(e.bottomSpacing))?void 0:Number(e.bottomSpacing):e.bottomSpacing,show_launcher:e.show_launcher,overrides:e.overrides,launcher_size:e.launcher_size});if(this.config=n,!e.api_key)throw rt.trackError(new Error(_t[at](e.api_key)),"RobylonChatbot",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}}),new Error("API key is required");try{rt.initialize(e.api_key,e.user_id)}catch(e){rt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:dt,errorType:vt,context:{timestamp:Date.now()}})}this.stateManager=function(e){var t={isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1},n=[],i=function(e){t=c(c({},t),e),n.forEach(function(e){return e(t)})};return{getState:function(){return t},initialize:function(){return d(void 0,void 0,void 0,function(){var t,n,o;return u(this,function(r){switch(r.label){case 0:if(!e.api_key)return rt.trackError(new Error(_t[at](e.api_key)),"ChatbotStateManager",{errorCode:at,errorType:vt,context:{timestamp:Date.now()}}),[2];i({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,kt(e)];case 2:return t=r.sent(),[4,new Promise(function(e,n){St(t,function(){i({isInitialized:!0,chatbotConfig:t}),e()},function(e){n(e)})})];case 3:return r.sent(),[3,6];case 4:return n=r.sent(),o=n instanceof Error?n.message:"Failed to initialize chatbot",i({error:o}),rt.trackError(n instanceof Error?n:new Error(o),"ChatbotStateManager",{errorCode:ct,errorType:vt,context:{timestamp:Date.now()}}),[3,6];case 5:return i({isInitializing:!1}),[7];case 6:return[2]}})})},toggleIframeVisibility:function(){i({isIframeVisible:!t.isIframeVisible})},closeIframe:function(){i({isIframeVisible:!1})},updateState:i,subscribe:function(e){return n.push(e),function(){var t=n.indexOf(e);t>-1&&n.splice(t,1)}},unsubscribe:function(e){var t=n.indexOf(e);t>-1&&n.splice(t,1)}}}({api_key:e.api_key,user_id:e.user_id,user_token:e.user_token,user_profile:e.user_profile}),this.eventEmitter=Ht({api_key:e.api_key,user_profile:e.user_profile,onEvent:e.onEvent,chatbotConfig:null}),this.initialize()}return e.prototype.initialize=function(){return d(this,void 0,void 0,function(){var e;return u(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.stateManager.initialize()];case 1:return t.sent(),this.stateManager.subscribe(this.handleStateChange),this.handleStateChange(this.stateManager.getState()),[3,3];case 2:return e=t.sent(),rt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot.initialize",{errorCode:ct,errorType:vt,context:{timestamp:Date.now()}}),[3,3];case 3:return[2]}})})},e.prototype.show=function(){var e,t,n=this.stateManager.getState();if("chat_widget"===(null===(e=null==n?void 0:n.chatbotConfig)||void 0===e?void 0:e.widget_type))n.isIframeVisible||(this.stateManager.toggleIframeVisibility(),this.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED));else{var i=null===(t=null==n?void 0:n.chatbotConfig)||void 0===t?void 0:t.redirect_chat_link;i&&(window.open(i,"_blank","noopener,noreferrer"),this.eventEmitter.emit(f.CHATBOT_BUTTON_CLICKED))}},e.prototype.hide=function(){var e,t=this.stateManager.getState();"chat_widget"===(null===(e=null==t?void 0:t.chatbotConfig)||void 0===e?void 0:e.widget_type)&&t.isIframeVisible&&(this.stateManager.closeIframe(),this.eventEmitter.emit(f.CHATBOT_CLOSED))},e.prototype.toggle=function(){this.toggleIframe()},e.prototype.destroy=function(){this.isDestroyed=!0,this.floatingButton&&(this.floatingButton.destroy(),this.floatingButton=null),this.launcherDelayTimeout&&(clearTimeout(this.launcherDelayTimeout),this.launcherDelayTimeout=null),this.popup&&(this.popup.destroy(),this.popup=null),this.container&&(this.container.destroy(),this.container=null),this.stateManager.unsubscribe(this.handleStateChange)},e.prototype.getState=function(){return this.stateManager.getState().isInitialized?"initialized":"uninitialized"},e}();function Pt(e){return new Ut(e)}if("undefined"!=typeof window){!function(){if("undefined"!=typeof window){var e=window,t=(null==e?void 0:e.RobylonChatbot)||(null==e?void 0:e.R);if(t&&Array.isArray(t.q)){var n=null;t.q.forEach(function(e){var t=e[0];if("init"===t){var i=e[1]||{};n=Pt(i)}else n&&"function"==typeof n[t]&&n[t]()}),e.RobylonChatbot=function(e){var t=Array.prototype.slice.call(arguments,1);return"init"===e?n=Pt(t[0]||{}):n&&"function"==typeof n[e]?n[e].apply(n,t):void 0},(null==e?void 0:e.R)||(e.R=e.RobylonChatbot),e.RobylonChatbot.getState=function(){return"initialized"},(null==e?void 0:e.R)&&(e.R.getState=e.RobylonChatbot.getState)}}}();var jt=window,Wt=null==jt?void 0:jt.RobylonChatbot;Wt&&!(null==jt?void 0:jt.R)&&(jt.R=Wt)}var Gt={create:Pt,getState:function(){return"initialized"}};exports.Chatbot=Lt,exports.RobylonChatbot=Gt,exports.useChatbot=function(t){var n=e.useState({isLoading:!0,isInitialized:!1,error:null}),i=n[0],o=n[1],r=function(e){o(function(t){return c(c({},t),{isInitialized:e})})},a=function(e){o(function(t){return c(c({},t),{error:e})})};return e.useEffect(function(){!function(){try{St(t,r,a)}catch(e){o(function(t){return c(c({},t),{error:e instanceof Error?e.message:"Failed to initialize SDK",isLoading:!1})})}}()},[t.chatbotId,t.userId]),i};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|