@robylon/web-react-sdk 1.1.55-alpha.4 → 2.0.0-alpha-staging.9

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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import e,{memo as t,useRef as n,useState as i,useEffect as o,useCallback as r,Component as a,useMemo as l,forwardRef as s,useImperativeHandle as c}from"react";var d=function(e,t){return d=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])},d(e,t)};var u,p,f,m,v,h,g,_,y=function(){return y=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},y.apply(this,arguments)};function b(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 w(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 E(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,function(e){e.WIDGET="WIDGET",e.POPOVER="POPOVER",e.EMBED="EMBED"}(u||(u={})),function(e){e.RIGHT="Right",e.LEFT="Left"}(p||(p={})),function(e){e.TEXT="TEXT",e.IMAGE="IMAGE",e.TEXTUAL_IMAGE="TEXTUAL_IMAGE"}(f||(f={})),function(e){e.WORKING_HOURS="WORKING_HOURS",e.ALWAYS="ALWAYS"}(m||(m={})),function(e){e.URL="URL"}(v||(v={})),function(e){e.AND="AND",e.OR="OR"}(h||(h={})),function(e){e.IS="IS",e.IS_NOT="IS_NOT",e.CONTAINS="CONTAINS",e.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",e.STARTS_WITH="STARTS_WITH",e.ENDS_WITH="ENDS_WITH"}(g||(g={})),function(e){e.BUTTON="BUTTON",e.TEXT="TEXT"}(_||(_={}));var I=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"},T={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(){}};T.log("Raw API_URL:","https://api.robylon.ai");var x={copilotUrl:"https://dev.chatbot.robylon.ai",environment:"production",apiUrl:"https://api.robylon.ai"};T.log("CONFIG",x);var A,S,C=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},O=function(){return{copilotUrl:x.copilotUrl||"https://app.robylon.ai",environment:x.environment||"production",apiUrl:x.apiUrl||"https://app.robylon.ai"}};!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"}(A||(A={})),function(e){e.CHAT_MOVED="CHAT_MOVED",e.CHATBOT_TOKEN_EXHAUSTED="CHATBOT_TOKEN_EXHAUSTED"}(S||(S={}));var R,D="system-ui, Inter, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",N="21px",L="",k=[],M=!1,z=function(){return"undefined"==typeof window?"":window.location.href},F=function(){return z()},P=function(){var e=z();e!==L&&(L=e,k.forEach((function(t){return t(e)})))},H=function(e){return M||U(),k.push(e),e(z()),function(){var t=k.indexOf(e);t>-1&&k.splice(t,1)}},U=function(){if(!M&&"undefined"!=typeof window){M=!0,L=z();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(P,0),i}};try{history.pushState=e("pushState"),history.replaceState=e("replaceState")}catch(e){}window.addEventListener("popstate",P),window.addEventListener("hashchange",P);var t=setInterval((function(){P()}),1e3);setInterval((function(){0===k.length&&(clearInterval(t),window.removeEventListener("popstate",P),window.removeEventListener("hashchange",P),M=!1)}),5e3)}},B=function(e,t,n,i){var o=t||"",r=z(),a=i||r,l=function(e,t){return-1!==t.indexOf(e)}(o,a);switch(n){case g.IS:return a===o;case g.IS_NOT:return a!==o;case g.CONTAINS:return l;case g.DOES_NOT_CONTAIN:return!l;case g.STARTS_WITH:return a.startsWith(o);case g.ENDS_WITH:return a.endsWith(o);default:return!1}},W=null,j=null,G=function(){W=F()},V=function(){return W===F()},Y=function(e){j=y({input_id:null},e)},X=function(){var e=j;return j=null,e},K=function(){return!0},J=((R={})[m.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)},R[m.ALWAYS]=K,R),Z=function(e){if(!e||V())return[];var t=z(),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?J[i]:K;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=h.OR,f=0,m=d;f<m.length;f++){var v=m[f];if(null==v?void 0:v.logical_condition)p=v.logical_condition;else{var g=v,y=B(null==g||g.type,(null==g?void 0:g.value)||"",null==g?void 0:g.condition,t);u=null===u?y:p===h.AND?u&&y:u||y}}(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)||_.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};
1
+ import e,{memo as n,useRef as t,useState as o,useEffect as i,useCallback as r,Component as l,useMemo as a,forwardRef as s,useImperativeHandle as c}from"react";var d=function(e,n){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},d(e,n)};var u,p,f,h,v,m,g,_,b=function(){return b=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e},b.apply(this,arguments)};function y(e,n,t,o){return new(t||(t=Promise))((function(i,r){function l(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(l,a)}s((o=o.apply(e,n||[])).next())}))}function w(e,n){var t,o,i,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return l.next=a(0),l.throw=a(1),l.return=a(2),"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function a(a){return function(s){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;l&&(l=0,a[0]&&(r=0)),r;)try{if(t=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,o=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(6===a[0]&&r.label<i[1]){r.label=i[1],i=a;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(a);break}i[2]&&r.ops.pop(),r.trys.pop();continue}a=n.call(e,r)}catch(e){a=[6,e],o=0}finally{t=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function E(e,n,t){if(t||2===arguments.length)for(var o,i=0,r=n.length;i<r;i++)!o&&i in n||(o||(o=Array.prototype.slice.call(n,0,i)),o[i]=n[i]);return e.concat(o||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.WIDGET="WIDGET",e.POPOVER="POPOVER",e.EMBED="EMBED"}(u||(u={})),function(e){e.RIGHT="Right",e.LEFT="Left"}(p||(p={})),function(e){e.TEXT="TEXT",e.IMAGE="IMAGE",e.TEXTUAL_IMAGE="TEXTUAL_IMAGE"}(f||(f={})),function(e){e.WORKING_HOURS="WORKING_HOURS",e.ALWAYS="ALWAYS"}(h||(h={})),function(e){e.URL="URL"}(v||(v={})),function(e){e.AND="AND",e.OR="OR"}(m||(m={})),function(e){e.IS="IS",e.IS_NOT="IS_NOT",e.CONTAINS="CONTAINS",e.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",e.STARTS_WITH="STARTS_WITH",e.ENDS_WITH="ENDS_WITH"}(g||(g={})),function(e){e.BUTTON="BUTTON",e.TEXT="TEXT"}(_||(_={}));var I=function(e,n){void 0===n&&(n=.5);var t=function(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,n,t,o){return n+n+t+t+o+o}));var n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:{r:0,g:0,b:0}}(e),o=function(e,n,t){var o=[e,n,t].map((function(e){return(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*o[0]+.7152*o[1]+.0722*o[2]}(t.r,t.g,t.b);return o>n?"#0E0E0F":"#FFFFFF"},T={log:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.log.apply(console,e)},error:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.error.apply(console,e)},warn:function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];console.warn.apply(console,e)},info:function(){}};T.log("Raw API_URL:","https://stage-api.robylon.ai");var S={copilotUrl:"https://staging.d2s3wsqyyond1h.amplifyapp.com",environment:"staging",apiUrl:"https://stage-api.robylon.ai"};T.log("CONFIG",S);var x,A,C=function(){return"undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement},O=function(){return{copilotUrl:S.copilotUrl||"https://app.robylon.ai",environment:S.environment||"production",apiUrl:S.apiUrl||"https://app.robylon.ai"}};!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"}(x||(x={})),function(e){e.CHAT_MOVED="CHAT_MOVED",e.CHATBOT_TOKEN_EXHAUSTED="CHATBOT_TOKEN_EXHAUSTED"}(A||(A={}));var D,R="system-ui, Inter, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",N="21px",L="",k=[],M=!1,z=function(){return"undefined"==typeof window?"":window.location.href},P=function(){return z()},H=function(){var e=z();e!==L&&(L=e,k.forEach((function(n){return n(e)})))},F=function(e){return M||U(),k.push(e),e(z()),function(){var n=k.indexOf(e);n>-1&&k.splice(n,1)}},U=function(){if(!M&&"undefined"!=typeof window){M=!0,L=z();var e=function(e){var n=history[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n.apply(this,e);return setTimeout(H,0),o}};try{history.pushState=e("pushState"),history.replaceState=e("replaceState")}catch(e){}window.addEventListener("popstate",H),window.addEventListener("hashchange",H);var n=setInterval((function(){H()}),1e3);setInterval((function(){0===k.length&&(clearInterval(n),window.removeEventListener("popstate",H),window.removeEventListener("hashchange",H),M=!1)}),5e3)}},B=function(e,n,t,o){var i=n||"",r=z(),l=o||r,a=function(e,n){return-1!==n.indexOf(e)}(i,l);switch(t){case g.IS:return l===i;case g.IS_NOT:return l!==i;case g.CONTAINS:return a;case g.DOES_NOT_CONTAIN:return!a;case g.STARTS_WITH:return l.startsWith(i);case g.ENDS_WITH:return l.endsWith(i);default:return!1}},W=null,j=null,V=function(){W=P()},G=function(){return W===P()},Y=function(e){j=b({input_id:null},e)},K=function(){var e=j;return j=null,e},X=function(){return!0},q=((D={})[h.WORKING_HOURS]=function(e,n){var t=n.getHours(),o=n.getMinutes();return(t>10||10===t&&o>=0)&&(t<19||19===t&&0===o)},D[h.ALWAYS]=X,D),J=function(e){if(!e||G())return[];var n=z(),t=new Date,o=[];return e.forEach((function(e){o.push.apply(o,function(e,n,t){var o=(null==e?void 0:e.send_time_type)||"",i=o?q[o]:X;if(!i||!i(e,t))return[];for(var r=(null==e?void 0:e.content_multiple)||[],l=(null==e?void 0:e.delay_type)||"time",a="time"===l?Math.max(0,1e3*Number((null==e?void 0:e.delay)||0)):0,s="scroll"===l?Number((null==e?void 0:e.scroll_threshold)||0):void 0,c=[],d=0;d<r.length;d++){for(var u=r[d],p=(null==u?void 0:u.message_display_attributes)||[],f=null,h=m.OR,v=0,g=p;v<g.length;v++){var b=g[v];if(null==b?void 0:b.logical_condition)h=b.logical_condition;else{var y=b,w=B(null==y||y.type,(null==y?void 0:y.value)||"",null==y?void 0:y.condition,n);f=null===f?w:h===m.AND?f&&w:f||w}}(null===f||f)&&(null==u?void 0:u.message)&&c.push({messageId:(null==e?void 0:e.message_id)||String(d),contentIndex:d,html:String(u.message),delayMs:a,delayType:l,scrollThreshold:s,contentId:u.content_id||null,messageDisplayType:(null==u?void 0:u.message_display_type)||_.TEXT,messageBubbleBg:null==u?void 0:u.message_bubble_bg,urlToGo:null==u?void 0:u.url_to_go})}return c}(e,n,t))})),o};
2
2
  /*! @license DOMPurify 3.3.0 | (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.0/LICENSE */
3
- const{entries:q,setPrototypeOf:Q,isFrozen:$,getPrototypeOf:ee,getOwnPropertyDescriptor:te}=Object;let{freeze:ne,seal:ie,create:oe}=Object,{apply:re,construct:ae}="undefined"!=typeof Reflect&&Reflect;ne||(ne=function(e){return e}),ie||(ie=function(e){return e}),re||(re=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)}),ae||(ae=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 le=Ee(Array.prototype.forEach),se=Ee(Array.prototype.lastIndexOf),ce=Ee(Array.prototype.pop),de=Ee(Array.prototype.push),ue=Ee(Array.prototype.splice),pe=Ee(String.prototype.toLowerCase),fe=Ee(String.prototype.toString),me=Ee(String.prototype.match),ve=Ee(String.prototype.replace),he=Ee(String.prototype.indexOf),ge=Ee(String.prototype.trim),_e=Ee(Object.prototype.hasOwnProperty),ye=Ee(RegExp.prototype.test),be=(we=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ae(we,t)});var we;function Ee(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 re(e,t,i)}}function Ie(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:pe;Q&&Q(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&($(t)||(t[i]=e),o=e)}e[o]=!0}return e}function Te(e){for(let t=0;t<e.length;t++){_e(e,t)||(e[t]=null)}return e}function xe(e){const t=oe(null);for(const[n,i]of q(e)){_e(e,n)&&(Array.isArray(i)?t[n]=Te(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=xe(i):t[n]=i)}return t}function Ae(e,t){for(;null!==e;){const n=te(e,t);if(n){if(n.get)return Ee(n.get);if("function"==typeof n.value)return Ee(n.value)}e=ee(e)}return function(){return null}}const Se=ne(["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"]),Ce=ne(["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"]),Oe=ne(["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"]),Re=ne(["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"]),De=ne(["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"]),Ne=ne(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Le=ne(["#text"]),ke=ne(["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"]),Me=ne(["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"]),ze=ne(["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"]),Fe=ne(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Pe=ie(/\{\{[\w\W]*|[\w\W]*\}\}/gm),He=ie(/<%[\w\W]*|[\w\W]*%>/gm),Ue=ie(/\$\{[\w\W]*/gm),Be=ie(/^data-[\-\w.\u00B7-\uFFFF]+$/),We=ie(/^aria-[\-\w]+$/),je=ie(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ge=ie(/^(?:\w+script|data):/i),Ve=ie(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ye=ie(/^html$/i),Xe=ie(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ke=Object.freeze({__proto__:null,ARIA_ATTR:We,ATTR_WHITESPACE:Ve,CUSTOM_ELEMENT:Xe,DATA_ATTR:Be,DOCTYPE_NAME:Ye,ERB_EXPR:He,IS_ALLOWED_URI:je,IS_SCRIPT_OR_DATA:Ge,MUSTACHE_EXPR:Pe,TMPLIT_EXPR:Ue});const Je=1,Ze=3,qe=7,Qe=8,$e=9,et=function(){return"undefined"==typeof window?null:window};var tt=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:et();const n=t=>e(t);if(n.version="3.3.0",n.removed=[],!t||!t.document||t.document.nodeType!==$e||!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,v=c.prototype,h=Ae(v,"cloneNode"),g=Ae(v,"remove"),_=Ae(v,"nextSibling"),y=Ae(v,"childNodes"),b=Ae(v,"parentNode");if("function"==typeof l){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let w,E="";const{implementation:I,createNodeIterator:T,createDocumentFragment:x,getElementsByTagName:A}=i,{importNode:S}=o;let C={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof q&&"function"==typeof b&&I&&void 0!==I.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:R,TMPLIT_EXPR:D,DATA_ATTR:N,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:k,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:z}=Ke;let{IS_ALLOWED_URI:F}=Ke,P=null;const H=Ie({},[...Se,...Ce,...Oe,...De,...Le]);let U=null;const B=Ie({},[...ke,...Me,...ze,...Fe]);let W=Object.seal(oe(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}})),j=null,G=null;const V=Object.seal(oe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Y=!0,X=!0,K=!1,J=!0,Z=!1,Q=!0,$=!1,ee=!1,te=!1,ie=!1,re=!1,ae=!1,we=!0,Ee=!1,Te=!0,Pe=!1,He={},Ue=null;const Be=Ie({},["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 We=null;const Ge=Ie({},["audio","video","img","source","image","track"]);let Ve=null;const Xe=Ie({},["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=Ie({},[tt,nt,it],fe);let st=Ie({},["mi","mo","mn","ms","mtext"]),ct=Ie({},["annotation-xml"]);const dt=Ie({},["title","style","font","a","script"]);let ut=null;const pt=["application/xhtml+xml","text/html"];let ft=null,mt=null;const vt=i.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!mt||mt!==e){if(e&&"object"==typeof e||(e={}),e=xe(e),ut=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ft="application/xhtml+xml"===ut?fe:pe,P=_e(e,"ALLOWED_TAGS")?Ie({},e.ALLOWED_TAGS,ft):H,U=_e(e,"ALLOWED_ATTR")?Ie({},e.ALLOWED_ATTR,ft):B,at=_e(e,"ALLOWED_NAMESPACES")?Ie({},e.ALLOWED_NAMESPACES,fe):lt,Ve=_e(e,"ADD_URI_SAFE_ATTR")?Ie(xe(Xe),e.ADD_URI_SAFE_ATTR,ft):Xe,We=_e(e,"ADD_DATA_URI_TAGS")?Ie(xe(Ge),e.ADD_DATA_URI_TAGS,ft):Ge,Ue=_e(e,"FORBID_CONTENTS")?Ie({},e.FORBID_CONTENTS,ft):Be,j=_e(e,"FORBID_TAGS")?Ie({},e.FORBID_TAGS,ft):xe({}),G=_e(e,"FORBID_ATTR")?Ie({},e.FORBID_ATTR,ft):xe({}),He=!!_e(e,"USE_PROFILES")&&e.USE_PROFILES,Y=!1!==e.ALLOW_ARIA_ATTR,X=!1!==e.ALLOW_DATA_ATTR,K=e.ALLOW_UNKNOWN_PROTOCOLS||!1,J=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Z=e.SAFE_FOR_TEMPLATES||!1,Q=!1!==e.SAFE_FOR_XML,$=e.WHOLE_DOCUMENT||!1,ie=e.RETURN_DOM||!1,re=e.RETURN_DOM_FRAGMENT||!1,ae=e.RETURN_TRUSTED_TYPE||!1,te=e.FORCE_BODY||!1,we=!1!==e.SANITIZE_DOM,Ee=e.SANITIZE_NAMED_PROPS||!1,Te=!1!==e.KEEP_CONTENT,Pe=e.IN_PLACE||!1,F=e.ALLOWED_URI_REGEXP||je,ot=e.NAMESPACE||it,st=e.MATHML_TEXT_INTEGRATION_POINTS||st,ct=e.HTML_INTEGRATION_POINTS||ct,W=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(W.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Z&&(X=!1),re&&(ie=!0),He&&(P=Ie({},Le),U=[],!0===He.html&&(Ie(P,Se),Ie(U,ke)),!0===He.svg&&(Ie(P,Ce),Ie(U,Me),Ie(U,Fe)),!0===He.svgFilters&&(Ie(P,Oe),Ie(U,Me),Ie(U,Fe)),!0===He.mathMl&&(Ie(P,De),Ie(U,ze),Ie(U,Fe))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?V.tagCheck=e.ADD_TAGS:(P===H&&(P=xe(P)),Ie(P,e.ADD_TAGS,ft))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?V.attributeCheck=e.ADD_ATTR:(U===B&&(U=xe(U)),Ie(U,e.ADD_ATTR,ft))),e.ADD_URI_SAFE_ATTR&&Ie(Ve,e.ADD_URI_SAFE_ATTR,ft),e.FORBID_CONTENTS&&(Ue===Be&&(Ue=xe(Ue)),Ie(Ue,e.FORBID_CONTENTS,ft)),Te&&(P["#text"]=!0),$&&Ie(P,["html","head","body"]),P.table&&(Ie(P,["tbody"]),delete j.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw be('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw be('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,E=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 E&&(E=w.createHTML(""));ne&&ne(e),mt=e}},_t=Ie({},[...Ce,...Oe,...Re]),yt=Ie({},[...De,...Ne]),bt=function(e){de(n.removed,{element:e});try{b(e).removeChild(e)}catch(t){g(e)}},wt=function(e,t){try{de(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){de(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ie||re)try{bt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Et=function(e){let t=null,n=null;if(te)e="<remove></remove>"+e;else{const t=me(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=I.createDocument(ot,"template",null);try{t.documentElement.innerHTML=rt?E:o}catch(e){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),ot===it?A.call(t,$?"html":"body")[0]:$?t.documentElement:r},It=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)},xt=function(e){return"function"==typeof s&&e instanceof s};function At(e,t,i){le(e,(e=>{e.call(n,t,i,mt)}))}const St=function(e){let t=null;if(At(C.beforeSanitizeElements,e,null),Tt(e))return bt(e),!0;const i=ft(e.nodeName);if(At(C.uponSanitizeElement,e,{tagName:i,allowedTags:P}),Q&&e.hasChildNodes()&&!xt(e.firstElementChild)&&ye(/<[/\w!]/g,e.innerHTML)&&ye(/<[/\w!]/g,e.textContent))return bt(e),!0;if(e.nodeType===qe)return bt(e),!0;if(Q&&e.nodeType===Qe&&ye(/<[/\w]/g,e.data))return bt(e),!0;if(!(V.tagCheck instanceof Function&&V.tagCheck(i))&&(!P[i]||j[i])){if(!j[i]&&Ot(i)){if(W.tagNameCheck instanceof RegExp&&ye(W.tagNameCheck,i))return!1;if(W.tagNameCheck instanceof Function&&W.tagNameCheck(i))return!1}if(Te&&!Ue[i]){const t=b(e)||e.parentNode,n=y(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=h(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,_(e))}}}return bt(e),!0}return e instanceof c&&!function(e){let t=b(e);t&&t.tagName||(t={namespaceURI:ot,tagName:"template"});const n=pe(e.tagName),i=pe(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(_t[n]):e.namespaceURI===tt?t.namespaceURI===it?"math"===n:t.namespaceURI===nt?"math"===n&&ct[i]:Boolean(yt[n]):e.namespaceURI===it?!(t.namespaceURI===nt&&!ct[i])&&!(t.namespaceURI===tt&&!st[i])&&!yt[n]&&(dt[n]||!_t[n]):!("application/xhtml+xml"!==ut||!at[e.namespaceURI]))}(e)?(bt(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!ye(/<\/no(script|embed|frames)/i,e.innerHTML)?(Z&&e.nodeType===Ze&&(t=e.textContent,le([O,R,D],(e=>{t=ve(t,e," ")})),e.textContent!==t&&(de(n.removed,{element:e.cloneNode()}),e.textContent=t)),At(C.afterSanitizeElements,e,null),!1):(bt(e),!0)},Ct=function(e,t,n){if(we&&("id"===t||"name"===t)&&(n in i||n in vt))return!1;if(X&&!G[t]&&ye(N,t));else if(Y&&ye(L,t));else if(V.attributeCheck instanceof Function&&V.attributeCheck(t,e));else if(!U[t]||G[t]){if(!(Ot(e)&&(W.tagNameCheck instanceof RegExp&&ye(W.tagNameCheck,e)||W.tagNameCheck instanceof Function&&W.tagNameCheck(e))&&(W.attributeNameCheck instanceof RegExp&&ye(W.attributeNameCheck,t)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(t,e))||"is"===t&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&ye(W.tagNameCheck,n)||W.tagNameCheck instanceof Function&&W.tagNameCheck(n))))return!1}else if(Ve[t]);else if(ye(F,ve(n,M,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==he(n,"data:")||!We[e]){if(K&&!ye(k,ve(n,M,"")));else if(n)return!1}else;return!0},Ot=function(e){return"annotation-xml"!==e&&me(e,z)},Rt=function(e){At(C.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Tt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:U,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:ge(d);if(i.attrName=c,i.attrValue=u,i.keepAttr=!0,i.forceKeepAttr=void 0,At(C.uponSanitizeAttribute,e,i),u=i.attrValue,!Ee||"id"!==c&&"name"!==c||(wt(a,e),u="user-content-"+u),Q&&ye(/((--!?|])>)|<\/(style|title|textarea)/i,u)){wt(a,e);continue}if("attributename"===c&&me(u,"href")){wt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){wt(a,e);continue}if(!J&&ye(/\/>/i,u)){wt(a,e);continue}Z&&le([O,R,D],(e=>{u=ve(u,e," ")}));const p=ft(e.nodeName);if(Ct(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)?bt(e):ce(n.removed)}catch(t){wt(a,e)}}else wt(a,e)}At(C.afterSanitizeAttributes,e,null)},Dt=function e(t){let n=null;const i=It(t);for(At(C.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)At(C.uponSanitizeShadowNode,n,null),St(n),Rt(n),n.content instanceof a&&e(n.content);At(C.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&&!xt(e)){if("function"!=typeof e.toString)throw be("toString is not a function");if("string"!=typeof(e=e.toString()))throw be("dirty is not a string, aborting")}if(!n.isSupported)return e;if(ee||gt(t),n.removed=[],"string"==typeof e&&(Pe=!1),Pe){if(e.nodeName){const t=ft(e.nodeName);if(!P[t]||j[t])throw be("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)i=Et("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===Je&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!ie&&!Z&&!$&&-1===e.indexOf("<"))return w&&ae?w.createHTML(e):e;if(i=Et(e),!i)return ie?null:ae?E:""}i&&te&&bt(i.firstChild);const d=It(Pe?e:i);for(;l=d.nextNode();)St(l),Rt(l),l.content instanceof a&&Dt(l.content);if(Pe)return e;if(ie){if(re)for(c=x.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(U.shadowroot||U.shadowrootmode)&&(c=S.call(o,c,!0)),c}let u=$?i.outerHTML:i.innerHTML;return $&&P["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&ye(Ye,i.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+u),Z&&le([O,R,D],(e=>{u=ve(u,e," ")})),w&&ae?w.createHTML(u):u},n.setConfig=function(){gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ee=!0},n.clearConfig=function(){mt=null,ee=!1},n.isValidAttribute=function(e,t,n){mt||gt({});const i=ft(e),o=ft(t);return Ct(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&de(C[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=se(C[e],t);return-1===n?void 0:ue(C[e],n,1)[0]}return ce(C[e])},n.removeHooks=function(e){C[e]=[]},n.removeAllHooks=function(){C={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),nt=function(e){return e?tt.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 it(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 ot,rt=t((function(t){var r,a,l,s,c,d,u,p,m,v,h,g,b,w,x,S,C,R,L=t.config,k=t.toggleIframe,M=t.isIframeVisible,z=t.onEvent,F=t.onInternalEvent,P=t.position,U=t.sideSpacing,B=t.bottomSpacing,W=t.launcher_type,j=t.launcher_properties_text,X=t.shouldFadeIn,K=t.launcher_size,J=n(null),q=O().copilotUrl,Q=i(!1),$=Q[0],ee=Q[1],te=i(!1),ne=te[0],ie=te[1],oe=i([]),re=oe[0],ae=oe[1],le=i(!1),se=le[0],ce=le[1],de=n([]),ue=n(),pe=n(new Set),fe=null!==(l=null==L?void 0:L.launcher_size_multiplier)&&void 0!==l?l:1,me=null!=K?K:48*fe;o((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;ee(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),o((function(){J.current&&requestAnimationFrame((function(){null==z||z({type:A.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),F(A.CHATBOT_BUTTON_LOADED)}))}),[z,F]),o((function(){if(J.current&&X){J.current.style.opacity="0";var e=requestAnimationFrame((function(){J.current&&(J.current.style.opacity="1")}));return function(){return cancelAnimationFrame(e)}}}),[X]);var ve=P||(null===(s=L.interface_properties)||void 0===s?void 0:s.position)||"Right",he=null!==(d=null!=U?U:null===(c=L.interface_properties)||void 0===c?void 0:c.side_spacing)&&void 0!==d?d:20,ge=null!==(p=null!=B?B:null===(u=L.interface_properties)||void 0===u?void 0:u.bottom_spacing)&&void 0!==p?p:20,_e=W||(null==L?void 0:L.launcher_type)||f.IMAGE,ye=j||(null===(m=null==L?void 0:L.launcher_properties)||void 0===m?void 0:m.text),be={zIndex:1e3,display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",boxSizing:"border-box"};_e===f.IMAGE&&(be.width="".concat(me,"px"),be.height="".concat(me,"px"),be.borderRadius="50%",be.backgroundColor=L.brand_colour);var we=y(y({},be),((r={position:void 0,bottom:"0",borderRadius:_e===f.IMAGE?"50%":"9999px"})[ve.toLowerCase()]="0",r)),Ee=y(y({},be),((a={position:"fixed",bottom:"".concat(ge,"px"),borderRadius:_e===f.IMAGE?"50%":"9999px"})[ve.toLowerCase()]="".concat(he,"px"),a)),Ie=$?Ee:we;o((function(){T.log("Screen width changed, isMobile:",$,"Style:",Ie)}),[$,Ie]),T.log("config in floating button",L);o((function(){var e=function(){de.current.forEach((function(e){return clearTimeout(e)})),de.current=[]},t=function(){if(e(),ae([]),pe.current.clear(),(null==L?void 0:L.proactive_message_obj)&&!V()){var t=Z(null==L?void 0:L.proactive_message_obj);E([],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(){ae((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),pe.current.add(n),setTimeout((function(){pe.current.delete(n)}),1200)}}))})),0===t?E(E([],e,!0),o,!0):E(E([],o,!0),e,!0)}))}),t);de.current.push(o)}))}};return ue.current=H((function(){ie(!1),t()})),t(),function(){var t;e(),null===(t=ue.current)||void 0===t||t.call(ue)}}),[null==L?void 0:L.proactive_message_obj]);var Te=re.length>0&&!M&&!ne,xe="Right"===(P||(null===(v=L.interface_properties)||void 0===v?void 0:v.position)||"Right"),Ae=function(){ce(!0),setTimeout((function(){ie(!0),G(),ce(!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(D,';\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 ')),Te?e.createElement("div",{className:"proactive-message-container",style:{position:"fixed",bottom:"".concat((null!==(g=null!=B?B:null===(h=L.interface_properties)||void 0===h?void 0:h.bottom_spacing)&&void 0!==g?g:20)+(_e===f.IMAGE?me:void 0!==K?40:40*fe)+8,"px"),right:xe?"".concat(null!==(w=null!=U?U:null===(b=L.interface_properties)||void 0===b?void 0:b.side_spacing)&&void 0!==w?w:20,"px"):"auto",left:xe?"auto":"".concat(null!==(S=null!=U?U:null===(x=L.interface_properties)||void 0===x?void 0:x.side_spacing)&&void 0!==S?S:20,"px"),maxWidth:"22.875rem",zIndex:2147483646}},e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:xe?"flex-end":"flex-start"},className:"proactive-message-bubble-container"},re.map((function(t,n){var i="".concat(t.id,"-").concat(t.index),o=pe.current.has(i),r=10*(re.length-1-n),a=t.messageDisplayType===_.BUTTON;return console.log("visibleProactives",re),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{Y({message_id:t.id,content_string:t.html||null,content_id:t.contentId||null}),k(),Ae();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:se?xe?"proactive-bubble-exit-right":"proactive-bubble-exit-left":o&&!se?xe?"proactive-bubble-enter-right":"proactive-bubble-enter-left":"",style:y({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:D,lineHeight:N,fontSize:"14px",marginBottom:n<re.length-1?16:0,border:"1px solid #F1F2F4",width:"fit-content",maxWidth:"100%",animationDelay:se?"0ms":o?"".concat(r,"ms"):void 0},se?{opacity:0}:o?{opacity:0,transform:xe?"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:it(t.html),dangerouslySetInnerHTML:{__html:nt(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:I((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(),Ae()},className:se?"":xe?"proactive-close-enter-right":"proactive-close-enter-left",style:y({position:"absolute",top:"-32px",right:"Right"===(P||(null===(C=L.interface_properties)||void 0===C?void 0:C.position)||"Right")?"0px":"auto",left:"Left"===(P||(null===(R=L.interface_properties)||void 0===R?void 0:R.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:se?"0ms":"".concat(10*(re.length-1),"ms")},se?{}:{opacity:0,transform:xe?"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:J,className:"message-bubble-container",style:y(y({},Ie),{transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",transform:M?"scale(0.85)":"scale(1)",opacity:X?0:1}),onClick:function(){k(),Ae()}},function(){switch(_e){case f.TEXT:return t=void 0!==K?void 0:160*fe,n=void 0!==K?void 0:40*fe,i=void 0!==K?void 0:14*fe,o=void 0!==K?void 0:21*fe,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:L.brand_colour,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box",fontFamily:D,lineHeight:N}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:it(ye),style:{margin:0,color:I(L.brand_colour),fontSize:void 0!==i?"".concat(i,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:D,lineHeight:void 0!==o?"".concat(o,"px"):N,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},ye)));case f.TEXTUAL_IMAGE:return function(){var t,n,i=void 0!==K?void 0:174*fe,o=void 0!==K?void 0:40*fe,r=void 0!==K?void 0:40*fe,a=void 0!==K?void 0:14*fe,l=void 0!==K?void 0:21*fe;return e.createElement("div",{style:{maxWidth:void 0!==i?"".concat(i,"px"):"13rem",width:"fit-content",height:void 0!==o?"".concat(o,"px"):"40px",borderRadius:"9999px",backgroundColor:L.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:D,lineHeight:N}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:it(ye),style:{margin:0,color:I(L.brand_colour),fontSize:void 0!==a?"".concat(a,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:D,lineHeight:void 0!==l?"".concat(l,"px"):N,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},ye)),e.createElement("div",{style:{width:void 0!==r?"".concat(r,"px"):"40px",height:void 0!==r?"".concat(r,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:0}},e.createElement("img",{src:(null==L?void 0:L.launcher_type)?(null===(n=null===(t=null==L?void 0:L.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(q,"/chatbubble.png"):(null==L?void 0:L.image_url)||"".concat(q,"/chatbubble.png"),alt:"Chat",style:{width:"100%",height:"100%",objectFit:"cover"}})))}();case f.IMAGE:default:return function(){var t,n;if(M){var i=Math.round(.5*me);return e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"}},e.createElement("svg",{width:i,height:i,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"}))))}return e.createElement("img",{src:(null==L?void 0:L.launcher_type)?(null===(n=null===(t=null==L?void 0:L.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(q,"/chatbubble.png"):(null==L?void 0:L.image_url)||"".concat(q,"/chatbubble.png"),alt:"Chat",style:{zIndex:1e3,cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box"}})}()}var t,n,i,o}()))})),at=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]},lt=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]},st=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)}},ct=function(){return{platform:"web",os:at(),browser:lt(),sdk_version:"1.1.55-alpha.4",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:st()};var e};!function(e){e.ERROR="ERROR",e.INFO="INFO"}(ot||(ot={}));var dt,ut,pt=["@robylon/web-react-sdk","node_modules/@robylon/web-react-sdk/"],ft=function(e){var t=e.filename,n=e.stack,i=e.message;return!!(t||n||i)&&pt.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))}))},mt=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};ft(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)};ft(o)&&e.trackError(t.reason||"Unhandled Promise Rejection","GlobalPromiseHandler",{reason:t.reason})},this.setupGlobalHandlers()}return e.prototype.setupGlobalHandlers=function(){C()&&(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(){C()&&(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:ct(),event_type:ot.ERROR,user_id:t};this.sendLog(n).catch(console.error)}this.apiKey=e,this.userId=t,this.isInitialized=!0,this.processPreInitQueue()}catch(n){T.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 b(this,void 0,void 0,(function(){var e,t,n;return w(this,(function(i){switch(i.label){case 0:if(!this.preInitQueue.length)return[2];T.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,y(y({},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 b(this,void 0,void 0,(function(){var t,n,i,o,r,a;return w(this,(function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),t=O().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=T).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(),T.error("Error sending log:",a),[3,5];case 5:return[2]}}))}))},e.prototype.trackError=function(e,t,n){return b(this,void 0,void 0,(function(){var i,o,r;return w(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:y(y({},n),{preInitError:!0,timestamp:Date.now()}),timestamp:Date.now()},metadata:ct(),event_type:ot.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}),T.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:y(y({},n),{timestamp:Date.now()}),timestamp:Date.now()},r={org_id:this.apiKey||"UNINITALIZED",event_data:o,metadata:ct(),event_type:ot.ERROR,user_id:this.userId},[4,this.sendLog(r)];case 6:return a.sent(),[2]}}))}))},e.prototype.trackInfo=function(e,t,n){return b(this,void 0,void 0,(function(){var i,o;return w(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:ct(),event_type:ot.INFO,user_id:this.userId},[4,this.sendLog(o)]):(T.error("Error tracking not initialized"),[2]);case 1:return r.sent(),[2]}}))}))},e}(),vt=mt.getInstance(),ht="MISSING_API_KEY",gt="INVALID_API_KEY",_t="CONFIG_FETCH_FAILED",yt="SDK_INIT_FAILED",bt="ERROR_TRACKING_INIT_FAILED",wt="API_REQUEST_FAILED",Et="NETWORK_ERROR",It="INVALID_RESPONSE",Tt="IFRAME_LOAD_FAILED",xt="COOKIE_ACCESS_ERROR",At="COMPONENT_RENDER_ERROR",St="INITIALIZATION_ERROR",Ct="API_ERROR",Ot="RUNTIME_ERROR",Rt="COMPONENT_ERROR",Dt=((dt={})[ht]=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.")},dt[gt]=function(e){return"SDK Initialization Failed: Provided API key '".concat(e,"' is invalid. API key must be a non-empty string in UUID format.")},dt[_t]=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):"")},dt[wt]=function(e,t,n){return"API Request Failed: Server responded with status ".concat(e," for ").concat(n?"endpoint ".concat(n):"request"," - ").concat(t)},dt[Et]=function(e){return"Network Error: Failed to communicate with server".concat(e.url?" at ".concat(e.url):"").concat(e.error?" - ".concat(e.error):"")},dt[Tt]=function(e){return"Failed to load chatbot interface".concat(e.src?" from ".concat(e.src):"").concat(e.error?". Error: ".concat(e.error):"")},dt[It]=function(e){return"Invalid API Response: Missing required fields in response data: ".concat(e.join(", "))},dt[bt]=function(e){return"Error Tracking Service initialization failed".concat(e.apiKey?" for API key ".concat(e.apiKey):"").concat(e.error?". Error: ".concat(e.error):"")},dt[yt]=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)):"")},dt[xt]=function(e,t){return"Cookie Access Error: Failed to ".concat(e).concat(t?" cookie '".concat(t,"'"):" cookies",". This may affect user session persistence.")},dt[At]=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):"")},dt),Nt=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"},Lt=function(){var e,t,n=ct();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:Nt(),os:null==n?void 0:n.os,referral_url:(null===document||void 0===document?void 0:document.referrer)||"",system_info:n}};!function(e){e.UPDATE_OVERRIDES="updateOverrides",e.I_CAN_AUTHENTICATE="i_can_authenticate",e.I_LOADED_LAUNCHER="i_loaded_launcher",e.I_OPENED_IFRAME="i_opened_iframe",e.I_CLICKED_PROACTIVE_BUBBLE="i_clicked_proactive_bubble",e.CAPTURED_SESSION_DATA="capturedSessionData",e.UPDATE_USER_PROFILE="updateUserProfile",e.OPENED_IFRAME_EVENT="openedIframe"}(ut||(ut={}));var kt=t((function(t){var i,a,l,s,c=t.config,d=t.isVisible,u=t.onClose,p=t.onEvent,f=t.onIframeLoaded,m=t.onInternalEvent,v=t.position,h=t.bottomSpacing,g=t.overrides,_=n(null),b=n(!1),w=n(!1);n();var E=n(!1),I=v||(null===(i=c.interface_properties)||void 0===i?void 0:i.position)||"Right",T=null!==(l=null!=h?h:null===(a=c.interface_properties)||void 0===a?void 0:a.bottom_spacing)&&void 0!==l?l:20,x=r((function(e,t){var n=_.current;(null==n?void 0:n.contentWindow)&&n.contentWindow.postMessage(e,t)}),[]),C=r((function(){var e,t=_.current;if(t){var n=((e={width:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vw":"26%",minWidth:(null===window||void 0===window?void 0:window.innerWidth)<560?"300px":"400px",height:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vh":"calc(100vh - 2rem - 10vh - ".concat(T,"px)"),borderRadius:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"1rem",position:(null===window||void 0===window?void 0:window.innerWidth)<560?"fixed":"",maxHeight:(null===window||void 0===window?void 0:window.innerWidth)<560?"100%":"50rem",top:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"calc(10vh - 32px)"})[I.toLowerCase()]=(null===window||void 0===window?void 0:window.innerWidth)<560?"0":void 0,e.flexDirection=(null===window||void 0===window?void 0:window.innerWidth)<560?"column":void 0,e.flexGrow=(null===window||void 0===window?void 0:window.innerWidth)<560?"1":void 0,e);Object.assign(t.style,n)}}),[T,I]);return o((function(){var e=_.current;if(e&&!b.current){var t=O().copilotUrl;Object.assign(e.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(I.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),e.src="".concat(t,"/chatbot-plugin?id=").concat(c.chatbotId),b.current=!0,C();var n=function(){var n,i,o,r,a,l,s,d,u,p,m,v,h=new URL(e.src).origin||t;if(x({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,name:"checkDomain"},h),g){var _={header_avatar:null!==(i=null==g?void 0:g.header_avatar)&&void 0!==i?i:null,agent_avatar:null!==(o=null==g?void 0:g.agent_avatar)&&void 0!==o?o:null,header_title:null!==(r=null==g?void 0:g.header_title)&&void 0!==r?r:null,header_subtitle:null!==(a=null==g?void 0:g.header_subtitle)&&void 0!==a?a:null,header_title_text_color:null!==(l=null==g?void 0:g.header_title_text_color)&&void 0!==l?l:null,header_subtitle_text_color:null!==(s=null==g?void 0:g.header_subtitle_text_color)&&void 0!==s?s:null,header_bg:null!==(d=null==g?void 0:g.header_bg)&&void 0!==d?d:null};x({domain:null===(u=null===window||void 0===window?void 0:window.location)||void 0===u?void 0:u.hostname,action:ut.UPDATE_OVERRIDES,data:_},t)}if(!(null==w?void 0:w.current)&&e.contentWindow){x({domain:null===(p=null===window||void 0===window?void 0:window.location)||void 0===p?void 0:p.hostname,action:ut.I_CAN_AUTHENTICATE,data:{show_history:null==c?void 0:c.show_history}},t);var b=X();x({domain:null===(m=null===window||void 0===window?void 0:window.location)||void 0===m?void 0:m.hostname,action:ut.I_LOADED_LAUNCHER,data:y(y({ws_url:null==c?void 0:c.ws_url,userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:y(y({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:y(y({},(null===(v=null==c?void 0:c.userProfile)||void 0===v?void 0:v.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null==c?void 0:c.isAnonymous},b?{proactiveData:b}:{}),{show_history:null==c?void 0:c.show_history})},t),w.current=!0}null==f||f()};return e.addEventListener("load",n),function(){return e.removeEventListener("load",n)}}}),[c.chatbotId,null===(s=c.interface_properties)||void 0===s?void 0:s.position,C,g]),o((function(){var e,t,n,i,o=_.current;if(o&&b.current){var r=(null===(e=c.interface_properties)||void 0===e?void 0:e.position)||"Right";if(d?(Object.assign(o.style,{transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"block"}),o.getBoundingClientRect(),setTimeout((function(){Object.assign(o.style,{transform:"scale(1) translate3d(0,0,0)",opacity:"1",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"})}),20)):(E.current=!1,o.style.transition="none",o.getBoundingClientRect(),Object.assign(o.style,{opacity:"0",transform:"scale(0.3) translate3d(".concat((r.toLowerCase(),"0"),",40px,0)"),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"}),setTimeout((function(){!d&&o&&(o.style.display="none")}),200)),o.contentWindow&&d){var a=O().copilotUrl;if(x({domain:null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.hostname,name:"openFrame"},a),E.current)E.current=!1;else{var l=X();console.log("proactiveData registerUserId===>",l),x({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,action:ut.I_OPENED_IFRAME,data:y(y({ws_url:null==c?void 0:c.ws_url,userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:y(y({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:y(y({},(null===(i=null==c?void 0:c.userProfile)||void 0===i?void 0:i.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null==c?void 0:c.isAnonymous},l?{proactiveData:l}:{}),{show_history:null==c?void 0:c.show_history})},a)}}}}),[d,c.userId,c.token,c.userProfile]),o((function(){var e=function(e){var t,n,i,o;if(_.current&&w.current){E.current=!0;var r=(null==e?void 0:e.detail)||{},a=O().copilotUrl;x({domain:null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.hostname,action:ut.I_CLICKED_PROACTIVE_BUBBLE,data:{userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:y(y({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:y(y({},(null===(n=null==c?void 0:c.userProfile)||void 0===n?void 0:n.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null==c?void 0:c.isAnonymous,ws_url:null==c?void 0:c.ws_url,proactiveData:{input_id:null,message_id:(null==r?void 0:r.message_id)||null,content_string:(null==r?void 0:r.content_string)||null,content_id:(null==r?void 0:r.content_id)||null},show_history:null==c?void 0:c.show_history}},a),console.log("message should have been sent===>",null===(i=_.current)||void 0===i?void 0:i.contentWindow,{userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:y(y({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:y(y({},(null===(o=null==c?void 0:c.userProfile)||void 0===o?void 0:o.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null==c?void 0:c.isAnonymous,ws_url:null==c?void 0:c.ws_url,proactiveData:{input_id:null,message_id:(null==r?void 0:r.message_id)||null,content_string:(null==r?void 0:r.content_string)||null,content_id:(null==r?void 0:r.content_id)||null}})}};return window.addEventListener("rblyn:proactiveClick",e),function(){return window.removeEventListener("rblyn:proactiveClick",e)}}),[null==c?void 0:c.userId,null==c?void 0:c.token,null==c?void 0:c.userProfile,null==c?void 0:c.isAnonymous]),o((function(){if(_.current&&b.current){var e=O().copilotUrl;d&&(null==p||p({type:A.CHATBOT_OPENED,timestamp:Date.now()}),m(A.CHATBOT_OPENED));var t=function(t){var n,i,o,r,a,l,s;if(t.origin===e){if("closeChatbot"===t.data)return void u();if("CHATBOT_TOKEN_EXHAUSTED"===(null===(n=t.data)||void 0===n?void 0:n.type))return void m(S.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null===(i=t.data)||void 0===i?void 0:i.type)&&(null==p||p({type:A.CHATBOT_LOADED,timestamp:Date.now()}),m(A.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null===(o=t.data)||void 0===o?void 0:o.type)&&(null==p||p({type:A.CHAT_INITIALIZED,timestamp:Date.now()}),m(A.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null===(r=t.data)||void 0===r?void 0:r.type)&&(null==p||p({type:A.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),m(A.CHAT_INITIALIZATION_FAILED,{error:null===(a=t.data)||void 0===a?void 0:a.error})),"SESSION_REFRESHED"===(null===(l=t.data)||void 0===l?void 0:l.type)&&(null==p||p({type:A.SESSION_REFRESHED,timestamp:Date.now()}),m(A.SESSION_REFRESHED)),"CHAT_MOVED"===(null===(s=t.data)||void 0===s?void 0:s.type)&&m(S.CHAT_MOVED,{from:t.data.from,to:t.data.to,trigger:t.data.trigger})}};return null===window||void 0===window||window.addEventListener("message",t),function(){return null===window||void 0===window?void 0:window.removeEventListener("message",t)}}}),[u,p,m,c.chatbotId,d]),o((function(){var e=_.current;if(e&&b.current){var t=function(){vt.trackError(new Error(Dt[Tt]({src:e.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:Tt,errorType:Ot,context:{config:c,iframeUrl:e.src,timestamp:Date.now()}})};return e.addEventListener("error",t),function(){return e.removeEventListener("error",t)}}}),[c]),o((function(){if(_.current&&c&&d){_.current;var e=O().copilotUrl;x({action:ut.UPDATE_USER_PROFILE,user_profile:c.userProfile,show_history:null==c?void 0:c.show_history},e),x({action:ut.OPENED_IFRAME_EVENT,user_profile:c.userProfile,show_history:null==c?void 0:c.show_history},e)}}),[c.userProfile,d]),e.createElement("iframe",{allow:"microphone",ref:_,id:"chat-iframe-rbyln",style:{display:"none"}})})),Mt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={hasError:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.getDerivedStateFromError=function(e){return{hasError:!0}},t.prototype.componentDidCatch=function(e,t){vt.trackError(new Error(Dt[At]({component:this.props.componentName||void 0,error:e.message,stack:t.componentStack})),this.props.componentName||void 0,{errorCode:At,errorType:Rt,context:{originalError:e,componentStack:t.componentStack,timestamp:Date.now()}})},t.prototype.render=function(){return this.state.hasError?null:this.props.children},t}(a),zt=function(e,t,n,i){return b(void 0,void 0,void 0,(function(){var o,r,a,l,s,c,d,u;return w(this,(function(p){switch(p.label){case 0:o=O().apiUrl,r="".concat(o,"/chat/chatbot/get/"),T.log("endpointUrl",r),a={client_user_id:t,org_id:e,token:n||void 0,internal_user_id:i||void 0,extra_info:{},launcher_info:Lt()},p.label=1;case 1:return p.trys.push([1,6,,7]),[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:return(l=p.sent()).ok?[3,4]:[4,l.text()];case 3:throw s=p.sent(),new Error(Dt[wt](l.status,s));case 4:return[4,l.json()];case 5:c=p.sent();try{String(a.org_id||"")}catch(e){}if(!(null===(u=null==c?void 0:c.user)||void 0===u?void 0:u.org_info))throw new Error(Dt[It](["user","org_info"]));return[2,c];case 6:throw d=p.sent(),vt.trackError(d instanceof Error?d:new Error(Dt[Et]({error:String(d)})),"fetchChatbotConfig",{errorCode:d instanceof Error&&d.message.includes("API Request Failed")?wt:Et,errorType:Ct,context:{chatbotId:e,userId:t,apiUrl:o,statusCode:d instanceof Response?d.status:void 0,timestamp:Date.now(),requestPayload:{client_user_id:t,org_id:e}}}),d;case 7:return[2]}}))}))},Ft=function(){return"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)}))},Pt=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()},Ht=function(e,t,n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3),document.cookie="".concat(e,"=").concat(t,";expires=").concat(i.toUTCString(),";path=/")},Ut=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},Bt=function(){function e(e){this.logoContainer=null,this.iframe=null,this.bubblePromptContainer=null,this.chatBtnImage=null,this.isIframeLoaded=!1,this.config=e,this.validateDomain()&&this.init(),null===window||void 0===window||window.addEventListener("message",this.onCloseListener.bind(this),!1)}return e.prototype.sendMessageToIframe=function(e,t){var n;(null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)&&this.iframe.contentWindow.postMessage(e,t)},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 T.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="&times;",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:I(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=document.createElement("img");i.src=this.config.launcher_type?(null===(n=null===(t=this.config.images)||void 0===t?void 0:t.launcher_image_url)||void 0===n?void 0:n.url)||"".concat(this.config.domain,"/chatbubble.png"):this.config.image_url||"".concat(this.config.domain,"/chatbubble.png"),i.alt="Chat",Object.assign(i.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover"}),this.chatBtnImage=i,e.innerHTML="",e.appendChild(i)},e.prototype.createIframe=function(){var e=this;T.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),T.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:y(y({},e.config.userProfile||{}),{__INT_SYS_INFO__:y(y({},(null===(a=e.config.userProfile)||void 0===a?void 0:a.__INT_SYS_INFO__)||{}),Lt())})}},l),e.isIframeLoaded=!0,e.createFloatingButton()}})),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:Ut(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;T.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;if(T.log("toggleIframe",this.iframe,this.logoContainer,this.chatBtnImage),this.iframe&&this.logoContainer&&this.chatBtnImage){var t=new URL(this.iframe.src).origin||this.config.domain;T.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"},t),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":"cover",this.bubblePromptContainer&&(this.bubblePromptContainer.style.display="none"),T.log("this.bubblePromptContainer",this.bubblePromptContainer)}},e.prototype.closeIframe=function(){this.iframe&&this.logoContainer&&this.chatBtnImage&&(this.iframe.style.display="none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="cover")},e.prototype.init=function(){this.createIframe()},e}(),Wt=function(e,t,n){if(e.chatbotId&&e.userId)try{new Bt(e);t(!0),T.log("Robylon SDK initialized successfully.")}catch(e){n(e instanceof Error?e.message:"Failed to initialize SDK")}else n("Incomplete configuration for SDK initialization.")},jt=function(e,t,n,i){return b(void 0,void 0,void 0,(function(){var o,r,a,l,s,c,d,u;return w(this,(function(p){switch(p.label){case 0:return p.trys.push([0,5,,6]),o=O().apiUrl,r="".concat(o,"/chat/chatbot/get/"),T.log("endpointUrl",r),a={client_user_id:t||null,org_id:e,token:n||void 0,internal_user_id:i||void 0,extra_info:{},launcher_info:Lt()},[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 1:return(l=p.sent()).ok?[3,3]:[4,l.text()];case 2:throw s=p.sent(),new Error(Dt[wt](l.status,s));case 3:return[4,l.json()];case 4:if(c=p.sent(),!(null===(u=null==c?void 0:c.user)||void 0===u?void 0:u.org_info))throw new Error(Dt[It](["user","org_info"]));return[2,c];case 5:throw d=p.sent(),vt.trackError(d instanceof Error?d:new Error(Dt[Et]({error:String(d)})),"fetchChatbotConfig",{errorCode:d instanceof Error&&d.message.includes("API Request Failed")?wt:Et,errorType:Ct,context:{apiKey:e,userId:t,timestamp:Date.now()}}),d;case 6:return[2]}}))}))},Gt=function(e){return b(void 0,void 0,void 0,(function(){var t,n,i,o,r,a,l,s,c,d,m,v,h,g,_,b,E,I,x,A,S,C,O,R,D,N,L,k,M,z,F,P,H,U,B,W,j,G,V;return w(this,(function(w){switch(w.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?o=Pt("rblyn_anon")||Ft():(n=Pt("rblyn_anon")||Ft(),Ht("rblyn_anon",n,365),i=!0,o=n),[4,jt(t.api_key,n,t.user_token,o)];case 1:r=w.sent();try{t.api_key}catch(e){T.warn("Failed to inject mock proactive messages",e)}return a=ct(),l=Lt(),Y=t.user_profile,s=Y?Object.fromEntries(Object.entries(Y).map((function(e){var t=e[0],n=e[1];return"boolean"==typeof n||"number"==typeof n?[t,n]:[t,String(n)]}))):{},c=y(y(y({},a),{__INT_SYS_INFO__:y(y({},a),l)}),s),[2,{chatbotId:t.api_key,userId:n,token:t.user_token,isAnonymous:i,domain:"",show_launcher:null===(m=null===(d=r.user.org_info)||void 0===d?void 0:d.show_launcher)||void 0===m||m,brand_colour:(null===(h=null===(v=r.user.org_info.brand_config)||void 0===v?void 0:v.colors)||void 0===h?void 0:h.brand_color)||"",image_url:(null===(_=null===(g=r.user.org_info)||void 0===g?void 0:g.brand_config)||void 0===_?void 0:_.launcher_logo_url)||"",userProfile:c,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(b=r.user.org_info.brand_config)||void 0===b?void 0:b.display_name)||"",welcome_message:(null===(E=r.user.org_info.brand_config)||void 0===E?void 0:E.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(I=r.user.org_info.brand_config)||void 0===I?void 0:I.redirect_url)||""},launcher_type:(null===(x=r.user.org_info.brand_config)||void 0===x?void 0:x.launcher_type)||f.IMAGE,launcher_properties:{text:(null===(S=null===(A=r.user.org_info.brand_config)||void 0===A?void 0:A.launcher_properties)||void 0===S?void 0:S.text)||""},images:{launcher_image_url:{url:(null===(R=null===(O=null===(C=r.user.org_info.brand_config)||void 0===C?void 0:C.images)||void 0===O?void 0:O.launcher_image_url)||void 0===R?void 0:R.url)||""}},proactive_message_obj:Vt(null===(L=null===(N=null===(D=null==r?void 0:r.user)||void 0===D?void 0:D.org_info)||void 0===N?void 0:N.brand_config)||void 0===L?void 0:L.proactive_message_obj),interface_properties:{position:(null===(M=null===(k=r.user.org_info.brand_config)||void 0===k?void 0:k.interface_properties)||void 0===M?void 0:M.position)||p.RIGHT,side_spacing:(null===(F=null===(z=r.user.org_info.brand_config)||void 0===z?void 0:z.interface_properties)||void 0===F?void 0:F.side_spacing)||20,bottom_spacing:(null===(H=null===(P=r.user.org_info.brand_config)||void 0===P?void 0:P.interface_properties)||void 0===H?void 0:H.bottom_spacing)||20},interface_type:(null===(U=r.user.org_info.brand_config)||void 0===U?void 0:U.interface_type)||u.WIDGET,launcher_delay:(null===(B=r.user.org_info.brand_config)||void 0===B?void 0:B.launcher_delay)||{enabled:!1,delay:0},launcher_size_multiplier:null!==(j=null===(W=r.user.org_info.brand_config)||void 0===W?void 0:W.launcher_size_multiplier)&&void 0!==j?j:1,ws_url:null===(V=null===(G=r.user)||void 0===G?void 0:G.router_connection_info)||void 0===V?void 0:V.url}]}var Y}))}))},Vt=function(e){if(e){var t=(Array.isArray(e)?e:[e]).filter(Boolean).map((function(e){var t,n,i={message_id:String(null!==(t=null==e?void 0:e.message_id)&&void 0!==t?t:""),org_id:String(null!==(n=null==e?void 0:e.org_id)&&void 0!==n?n:""),name:null==e?void 0:e.name,content:null==e?void 0:e.content,send_time_type:null==e?void 0:e.send_time_type,created_by_name:null==e?void 0:e.created_by_name,updated_by_name:null==e?void 0:e.updated_by_name,updated_at:null==e?void 0:e.updated_at,created_at:null==e?void 0:e.created_at,delay:"number"==typeof(null==e?void 0:e.delay)?e.delay:void 0,content_multiple:Array.isArray(null==e?void 0:e.content_multiple)?e.content_multiple:(null==e?void 0:e.content)?[{message:String(e.content),message_display_attributes:[]}]:[]};return(null==e?void 0:e.content)&&!(null==e?void 0:e.content_multiple)&&T.warn("[Robylon SDK] proactive_message.content is deprecated; use content_multiple[].message instead."),i}));return t.length?t:void 0}},Yt=function(e){var t=l((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||{}}}(e)}),[e.api_key,e.user_id,e.user_token,JSON.stringify(e.user_profile)]),n=i({isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1}),a=n[0],s=n[1],c=l((function(){return t.user_profile?Object.fromEntries(Object.entries(t.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(t.user_profile)]),d=r((function(e){s((function(t){return y(y({},t),e)}))}),[]),m=r((function(){return b(void 0,void 0,void 0,(function(){var e,n,i,o,r,a,l,s,m,v,h,g,_,b,E,I,T,x,A,S,C,O,R,D,N,L,k,M,z,F,P,H,U,B,W,j,G,V,Y,X,K,J,Z,q,Q,$,ee;return w(this,(function(w){switch(w.label){case 0:if(!t.api_key)return vt.trackError(new Error(Dt[ht](t.api_key)),"useChatbotState",{errorCode:ht,errorType:St,context:{timestamp:Date.now()}}),[2];d({isInitializing:!0}),w.label=1;case 1:return w.trys.push([1,4,5,6]),e=t.user_id||void 0,n=!1,i=void 0,e?i=Pt("rblyn_anon")||Ft():(e=Pt("rblyn_anon")||Ft(),i=e,Ht("rblyn_anon",e,365),n=!0),[4,zt(t.api_key,e,t.user_token,i)];case 2:return o=w.sent(),r=ct(),a=Lt(),l=y(y(y(y({},r),{__INT_SYS_INFO__:y(y({},r),a)}),c),{internal_user_id:i}),s={chatbotId:t.api_key,userId:e,token:t.user_token,isAnonymous:n,domain:"",show_launcher:null===(g=null===(h=o.user.org_info)||void 0===h?void 0:h.show_launcher)||void 0===g||g,show_history:null===(E=null===(b=null===(_=null==o?void 0:o.user)||void 0===_?void 0:_.org_info)||void 0===b?void 0:b.brand_config)||void 0===E?void 0:E.enable_history,brand_colour:(null===(T=null===(I=o.user.org_info.brand_config)||void 0===I?void 0:I.colors)||void 0===T?void 0:T.brand_color)||"",image_url:(null===(A=null===(x=o.user.org_info)||void 0===x?void 0:x.brand_config)||void 0===A?void 0:A.launcher_logo_url)||"",userProfile:l,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(S=o.user.org_info.brand_config)||void 0===S?void 0:S.display_name)||"",welcome_message:(null===(C=o.user.org_info.brand_config)||void 0===C?void 0:C.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(O=o.user.org_info.brand_config)||void 0===O?void 0:O.redirect_url)||""},interface_properties:{position:(null===(D=null===(R=o.user.org_info.brand_config)||void 0===R?void 0:R.interface_properties)||void 0===D?void 0:D.position)||p.RIGHT,side_spacing:null!==(k=null===(L=null===(N=o.user.org_info.brand_config)||void 0===N?void 0:N.interface_properties)||void 0===L?void 0:L.side_spacing)&&void 0!==k?k:20,bottom_spacing:null!==(F=null===(z=null===(M=o.user.org_info.brand_config)||void 0===M?void 0:M.interface_properties)||void 0===z?void 0:z.bottom_spacing)&&void 0!==F?F:20},interface_type:(null===(P=o.user.org_info.brand_config)||void 0===P?void 0:P.interface_type)||u.WIDGET,launcher_type:(null===(H=o.user.org_info.brand_config)||void 0===H?void 0:H.launcher_type)||f.IMAGE,launcher_properties:{text:(null===(B=null===(U=o.user.org_info.brand_config)||void 0===U?void 0:U.launcher_properties)||void 0===B?void 0:B.text)||""},images:{launcher_image_url:{url:(null===(G=null===(j=null===(W=o.user.org_info.brand_config)||void 0===W?void 0:W.images)||void 0===j?void 0:j.launcher_image_url)||void 0===G?void 0:G.url)||""}},proactive_message_obj:Vt(null===(X=null===(Y=null===(V=null==o?void 0:o.user)||void 0===V?void 0:V.org_info)||void 0===Y?void 0:Y.brand_config)||void 0===X?void 0:X.proactive_message_obj),launcher_delay:(null===(J=null===(K=o.user.org_info)||void 0===K?void 0:K.brand_config)||void 0===J?void 0:J.launcher_delay)||{enabled:!1,delay:0},launcher_size_multiplier:null!==(Q=null===(q=null===(Z=o.user.org_info)||void 0===Z?void 0:Z.brand_config)||void 0===q?void 0:q.launcher_size_multiplier)&&void 0!==Q?Q:1,ws_url:null===(ee=null===($=o.user)||void 0===$?void 0:$.router_connection_info)||void 0===ee?void 0:ee.url},[4,new Promise((function(e,t){Wt(s,(function(){d({isInitialized:!0,chatbotConfig:s}),e()}),(function(e){t(e)}))}))];case 3:return w.sent(),[3,6];case 4:return m=w.sent(),v=m instanceof Error?m.message:"Failed to initialize chatbot",d({error:v}),vt.trackError(m instanceof Error?m:new Error(v),"useChatbotState",{errorCode:yt,errorType:St,context:{timestamp:Date.now()}}),[3,6];case 5:return d({isInitializing:!1}),[7];case 6:return[2]}}))}))}),[t.api_key,t.user_id,t.user_token]);o((function(){t.api_key&&m()}),[m]),o((function(){a.chatbotConfig&&s((function(e){return y(y({},e),{chatbotConfig:y(y({},e.chatbotConfig),{userProfile:y(y({},ct()),c)})})}))}),[c]);var v=r((function(){s((function(e){return y(y({},e),{isIframeVisible:!e.isIframeVisible})}))}),[]),h=r((function(){d({isIframeVisible:!1})}),[]);return y(y({},a),{toggleIframeVisibility:v,closeIframe:h})},Xt=function(t){var n,r,a,l,s,c,d,u=t.children,p=t.config,f=t.position,m=t.sideSpacing,v=t.bottomSpacing,h=i(!1),g=h[0],_=h[1];o((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;_(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var b=f||(null===(a=p.interface_properties)||void 0===a?void 0:a.position)||"Right",w=null!==(s=null!=m?m:null===(l=p.interface_properties)||void 0===l?void 0:l.side_spacing)&&void 0!==s?s:20,E=null!==(d=null!=v?v:null===(c=p.interface_properties)||void 0===c?void 0:c.bottom_spacing)&&void 0!==d?d:20;T.log("config",p,b,w);var I={position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column"},x=y(y({},I),((n={bottom:"".concat(E,"px")})[b.toLowerCase()]="".concat(null!=w?w:20,"px"),n.alignItems="Right"===b?"flex-end":"flex-start",n.top=void 0,n["Right"===b?"left":"right"]=void 0,n)),A=y(y({},I),((r={top:0})[b.toLowerCase()]="".concat(null!=w?w:20,"px"),r.alignItems="center",r.bottom=void 0,r["Right"===b?"left":"right"]=void 0,r)),S=g?A:x;return o((function(){console.log("Container screen width changed, isMobile:",g,"Style:",S)}),[g,S]),e.createElement("div",{className:"robylon-chatbot-container",style:S},u)},Kt=s((function(t,n){var a,s,d,u=t.api_key,p=t.user_id,f=t.user_token,m=t.user_profile,v=t.onEvent,h=t.position,g=t.sideSpacing,_=t.bottomSpacing,I=t.show_launcher,x=t.launcher_type,S=t.launcher_properties_text,C=t.overrides,R=t.launcher_size,D="string"==typeof g?""===g||isNaN(Number(g))?void 0:Number(g):g,N="string"==typeof _?""===_||isNaN(Number(_))?void 0:Number(_):_,L="string"==typeof h?"left"===h.toLowerCase()?"Left":"right"===h.toLowerCase()?"Right":void 0:h;o((function(){}));var k=l((function(){return{api_key:u,user_id:p,user_token:f,user_profile:m}}),[u,p,f,m]),M=r((function(e){null==v||v(e)}),[v]),z=Yt(k),F=z.isInitialized,P=z.error,H=z.chatbotConfig,U=z.isIframeVisible,B=z.toggleIframeVisibility,W=z.closeIframe,j=l((function(){return{api_key:u,user_profile:k.user_profile,onEvent:M,chatbotConfig:H?{isAnonymous:H.isAnonymous,userId:H.userId}:null}}),[u,k.user_profile,M,null==H?void 0:H.isAnonymous,null==H?void 0:H.userId]),G=function(e){var t=e.api_key,n=e.chatbotConfig,i=e.user_profile,o=e.onEvent,a=l((function(){return{isAnonymous:(null==n?void 0:n.isAnonymous)||!1,userId:(null==n?void 0:n.userId)||""}}),[null==n?void 0:n.isAnonymous,null==n?void 0:n.userId]),s=l((function(){return i||{}}),[JSON.stringify(i)]),c=r((function(e){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return b(void 0,E([e],n,!0),void 0,(function(e,n){var i,o,r,l,c,d,u;return void 0===n&&(n={}),w(this,(function(p){switch(p.label){case 0:if(!t)return[2];p.label=1;case 1:return p.trys.push([1,3,,4]),i=O().apiUrl,o=ct(),r=y({trigger_time:Date.now(),channel:"CHATBOT",launch_url:(null===(u=null===window||void 0===window?void 0:window.location)||void 0===u?void 0:u.href)||"",org_id:t,client_user_id:a.isAnonymous?"Anonymous":String(a.userId),event_type:e,user_profile:s},n),l={org_id:t,event_data:r,metadata:y({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(l)})];case 2:if(!(c=p.sent()).ok)throw new Error("Failed to send internal event: ".concat(c.statusText));return[3,4];case 3:return d=p.sent(),T.error("Failed to send internal event:",d),[3,4];case 4:return[2]}}))}))}),[t,a]);return{emitEvent:r((function(e,t){var n=Date.now();e!==A.CHATBOT_BUTTON_CLICKED&&e!==A.CHATBOT_CLOSED&&e!==A.CHATBOT_OPENED&&e!==A.CHATBOT_READY||(o&&o({type:e,timestamp:n,data:t}),c(e,{timestamp:n}))}),[o,c]),onInternalEvent:c}}(y({},j)),V=G.emitEvent,Y=G.onInternalEvent;c(n,(function(){return{show:function(){F&&H?U||(B(),V(A.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot show - chatbot not ready yet")},hide:function(){F&&H?U&&(W(),V(A.CHATBOT_CLOSED)):console.warn("Robylon Chatbot: Cannot hide - chatbot not ready yet")},toggle:function(){F&&H?(B(),V(U?A.CHATBOT_CLOSED:A.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot toggle - chatbot not ready yet")},isReady:F&&!!H}}),[F,H,U,B,W,V]),o((function(){F&&H&&V(A.CHATBOT_READY)}),[F,H,V]);var X=i(!1),K=X[0],J=X[1],Z=i(!1),q=Z[0],Q=Z[1];o((function(){var e,t,n,i,o,r,a;if(!(void 0!==I?Boolean(I):null===(e=null==H?void 0:H.show_launcher)||void 0===e||e))return J(!1),function(){a&&clearTimeout(a)};var l=!0===(null===(t=null==H?void 0:H.launcher_delay)||void 0===t?void 0:t.enabled),s=null!==(r=null!==(i=null===(n=null==H?void 0:H.launcher_delay)||void 0===n?void 0:n.seconds)&&void 0!==i?i:null===(o=null==H?void 0:H.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)}}),[I,null==H?void 0:H.show_launcher,null===(a=null==H?void 0:H.launcher_delay)||void 0===a?void 0:a.enabled,null===(s=null==H?void 0:H.launcher_delay)||void 0===s?void 0:s.seconds,null===(d=null==H?void 0:H.launcher_delay)||void 0===d?void 0:d.delay]),o((function(){if(u)try{vt.initialize(u,p)}catch(e){vt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:bt,errorType:St,context:{timestamp:Date.now()}})}else vt.trackError(new Error(Dt[ht](u)),"RobylonChatbot",{errorCode:ht,errorType:St,context:{timestamp:Date.now()}})}),[u,p]);var $=r((function(){W(),V(A.CHATBOT_CLOSED)}),[W,V]),ee=r((function(){B(),V(U?A.CHATBOT_CLOSED:A.CHATBOT_BUTTON_CLICKED)}),[B,V,U]),te=l((function(){var e,t,n,i,o;return{config:H,toggleIframe:ee,isIframeVisible:U,onEvent:M,onInternalEvent:Y,position:L,sideSpacing:D,bottomSpacing:N,launcher_type:x,launcher_properties_text:S,shouldFadeIn:!0===(null===(e=null==H?void 0:H.launcher_delay)||void 0===e?void 0:e.enabled)&&(null!==(o=null!==(n=null===(t=null==H?void 0:H.launcher_delay)||void 0===t?void 0:t.seconds)&&void 0!==n?n:null===(i=null==H?void 0:H.launcher_delay)||void 0===i?void 0:i.delay)&&void 0!==o?o:0)>0||!1,launcher_size:R}}),[H,ee,U,M,Y,L,D,N,x,S,R]);T.log("floatingButtonProps",te);var ne=l((function(){return{config:H,isVisible:U,onClose:$,onEvent:M,onIframeLoaded:function(){return Q(!0)},onInternalEvent:Y,position:L,bottomSpacing:N,overrides:C}}),[H,U,$,M,Y,L,N,C]);return u&&!P&&H?e.createElement(Mt,{componentName:"RobylonChatbot"},F?e.createElement(Xt,{config:H,position:L,sideSpacing:D,bottomSpacing:N},e.createElement(Mt,{componentName:"ChatbotIframe"},e.createElement(kt,y({},ne))),e.createElement(Mt,{componentName:"ChatbotFloatingButton"},K&&q?e.createElement(rt,y({},te)):null)):null):null})),Jt=t(Kt,(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})),Zt=function(e){var t=i({isLoading:!0,isInitialized:!1,error:null}),n=t[0],r=t[1],a=function(e){r((function(t){return y(y({},t),{isInitialized:e})}))},l=function(e){r((function(t){return y(y({},t),{error:e})}))};return o((function(){!function(){try{Wt(e,a,l)}catch(e){r((function(t){return y(y({},t),{error:e instanceof Error?e.message:"Failed to initialize SDK",isLoading:!1})}))}}()}),[e.chatbotId,e.userId]),n},qt=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=H((function(){t.clearProactiveDelays(),t.renderProactiveIfNeeded(!0)}))}return e.prototype.render=function(){var e,t,n=this;O().copilotUrl;var 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:D};o.launcher_type===f.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=this.config,r=o.config,a=o.isIframeVisible,l=O().copilotUrl,s=null!==(e=null==r?void 0:r.launcher_size_multiplier)&&void 0!==e?e:1,c=null!==(t=this.config.launcher_size)&&void 0!==t?t:48*s;switch(console.log("config in floating button",r),r.launcher_type){case f.TEXT:return this.createTextLauncher();case f.TEXTUAL_IMAGE:return this.createTextualImageLauncher();case f.IMAGE:default:if(a){var d=Math.round(.5*c),u=document.createElement("div");Object.assign(u.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"});var p=document.createElementNS("http://www.w3.org/2000/svg","svg");p.setAttribute("width",String(d)),p.setAttribute("height",String(d)),p.setAttribute("viewBox","0 0 24 24"),p.setAttribute("fill","none"),p.setAttribute("xmlns","http://www.w3.org/2000/svg"),p.style.display="block";var m=document.createElementNS("http://www.w3.org/2000/svg","path");return m.setAttribute("d","M19 9L12 16L5 9"),m.setAttribute("stroke","currentColor"),m.setAttribute("stroke-width","1.5"),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),p.appendChild(m),u.appendChild(p),u}var v=document.createElement("img");return v.src=r.launcher_type?(null===(i=null===(n=r.images)||void 0===n?void 0:n.launcher_image_url)||void 0===i?void 0:i.url)||"".concat(l,"/chatbubble.png"):r.image_url||"".concat(l,"/chatbubble.png"),v.alt="Chat",Object.assign(v.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box"}),v}},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:I(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"):N,fontFamily:D,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=O().copilotUrl,l=this.config.config,s=l.brand_colour,c=l.launcher_properties,d=l.image_url,u=l.launcher_size_multiplier,p=null!=u?u:1,f=void 0!==this.config.launcher_size?void 0:174*p,m=void 0!==this.config.launcher_size?void 0:40*p,v=void 0!==this.config.launcher_size?void 0:40*p,h=void 0!==this.config.launcher_size?void 0:14*p,g=void 0!==this.config.launcher_size?void 0:21*p,_=document.createElement("div");Object.assign(_.style,{maxWidth:void 0!==f?"".concat(f,"px"):"13rem",width:"fit-content",height:void 0!==m?"".concat(m,"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 y=document.createElement("div");Object.assign(y.style,{flex:"1",minWidth:"0"});var b=document.createElement("p");Object.assign(b.style,{margin:"0",color:I(s),fontSize:void 0!==h?"".concat(h,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==g?"".concat(g,"px"):N,fontFamily:D,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),b.textContent=(null==c?void 0:c.text)||"";var w=document.createElement("div");Object.assign(w.style,{width:void 0!==v?"".concat(v,"px"):"40px",height:void 0!==v?"".concat(v,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:"0"});var E=document.createElement("img");return E.src=(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===(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)||"".concat(a,"/chatbubble.png"):d||"".concat(a,"/chatbubble.png"),E.alt="Chat",Object.assign(E.style,{width:"100%",height:"100%",objectFit:"cover"}),y.appendChild(b),w.appendChild(E),_.appendChild(y),_.appendChild(w),_},e.prototype.applyResponsiveStyles=function(e){var t,n,i,o,r,a,l,s,c,d=(null===window||void 0===window?void 0:window.innerWidth)<560,u=this.config.config,p=this.config.position||(null===(i=u.interface_properties)||void 0===i?void 0:i.position)||"Right",f=null!==(a=null!==(o=this.config.sideSpacing)&&void 0!==o?o:null===(r=u.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==a?a:20,m=null!==(c=null!==(l=this.config.bottomSpacing)&&void 0!==l?l:null===(s=u.interface_properties)||void 0===s?void 0:s.bottom_spacing)&&void 0!==c?c:20;this.buttonElement.style.position="",this.buttonElement.style.bottom="",this.buttonElement.style.right="",this.buttonElement.style.left="";var v=y(y({},e),d?((t={position:"fixed",bottom:"".concat(m,"px")})[p.toLowerCase()]="".concat(f,"px"),t):((n={bottom:"".concat(m,"px")})[p.toLowerCase()]="".concat(f,"px"),n));Object.assign(this.buttonElement.style,v)},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!==f.IMAGE?"9999px":"50%",boxSizing:"border-box"};this.config.config.launcher_type===f.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:A.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),e.config.onInternalEvent(A.CHATBOT_BUTTON_LOADED)}))},e.prototype.update=function(e){this.config.isIframeVisible,this.config=y(y({},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;G();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(D,' !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,p,m,v,h,g=this,y=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(y)&&!this.config.isIframeVisible&&!V()){if(this.injectAnimationStyles(),!this.proactiveElement){var b=document.createElement("div");b.style.position="fixed";var w=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,x=this.config.position||(null===(d=this.config.config.interface_properties)||void 0===d?void 0:d.position)||"Right",A=null!==(p=null===(u=this.config.config)||void 0===u?void 0:u.launcher_size_multiplier)&&void 0!==p?p:1,S=null!==(m=this.config.launcher_size)&&void 0!==m?m:48*A,C=this.config.config.launcher_type===f.IMAGE?S:void 0!==this.config.launcher_size?40:40*A;b.style.bottom="".concat(w+C+8,"px"),"Right"===x?b.style.right="".concat(T,"px"):b.style.left="".concat(T,"px"),b.style.maxWidth="22.875rem",b.style.zIndex="2147483646";var O=document.createElement("div");O.style.display="flex",O.style.flexDirection="column",O.style.alignItems="Right"===x?"flex-end":"flex-start";var R=document.createElement("div");R.style.position="absolute",R.style.top="-32px",R.style.width="24px",R.style.height="24px",R.style.borderRadius="50%",R.style.background="#fff",R.style.boxShadow="0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",R.style.display="flex",R.style.alignItems="center",R.style.justifyContent="center",R.style.cursor="pointer",R.style.opacity="0",R.style.visibility="hidden","Right"===(this.config.position||(null===(v=this.config.config.interface_properties)||void 0===v?void 0:v.position)||"Right")?(R.style.right="0px",R.style.left="auto",R.style.transform="translateX(120%) scale(0.95)"):(R.style.left="0px",R.style.right="auto",R.style.transform="translateX(-120%) scale(0.95)"),R.onclick=function(e){e.stopPropagation(),g.hideProactiveMessages()},R.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 ',b.appendChild(O),b.appendChild(R),document.body.appendChild(b),this.proactiveElement=b}var L=this.proactiveElement.children[0];L.innerHTML="";var k="Right"===(this.config.position||(null===(h=this.config.config.interface_properties)||void 0===h?void 0:h.position)||"Right");L.style.display="flex",L.style.flexDirection="column",L.style.alignItems=k?"flex-end":"flex-start",this.clearProactiveDelays();var M=Z(y);E([],M,!0).sort((function(e,t){return e.delayMs!==t.delayMs?e.delayMs-t.delayMs:e.contentIndex-t.contentIndex}));var z=new Map;M.forEach((function(e){var t=z.get(e.delayMs);t||(t={messageIds:[],groups:new Map},z.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 F=void 0!==z.get(0),P=this.proactiveElement.children[1];if(P&&M.length>0){P.style.opacity="0",P.style.visibility="hidden",P.style.transform=k?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var H=function(){if(P){P.style.visibility="visible";var e=L.children.length,t=e>0?10*(e-1):0;P.style.animationDelay="".concat(t,"ms"),P.className=k?"rblyn-proactive-close-enter-right":"rblyn-proactive-close-enter-left"}};if(F){var U=window.setTimeout(H,0);this.delayTimers.push(U)}else{var B=Math.min.apply(Math,Array.from(z.keys()));U=window.setTimeout(H,B);this.delayTimers.push(U)}}else P&&(P.style.opacity="0",P.style.visibility="hidden");var W=0;z.forEach((function(e,t){var n=e.messageIds,i=e.groups,o=window.setTimeout((function(){var e=L.children.length,o=0,r=[];n.forEach((function(e){var t=i.get(e)||[];E([],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?E([],r,!0).reverse():r;a.forEach((function(n,i){var r,l=n.item,s=document.createElement("div"),c=l.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=D,s.style.fontSize="14px",s.style.lineHeight=String(N),s.style.width="fit-content",s.style.maxWidth="100%";var d=0===i,u=i===a.length-1,p=e>0,f=z.has(0),m=!1;0===t?m=!u||d&&p:d&&(p||f)?m=!0:d||(m=!0),m&&(s.style.marginBottom="16px");var v=10*(e+o-1-(0===t?e+W:W));s.className=k?"rblyn-proactive-enter-right":"rblyn-proactive-enter-left",s.style.animationDelay="".concat(v,"ms"),s.style.opacity="0",s.style.transform=k?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var h=document.createElement("div");Object.assign(h.style,{display:"flex",alignItems:"center",gap:"8px"});var y=document.createElement("div");if(y.className="rblyn-proactive-message-content",y.setAttribute("dir",it(l.html)),y.innerHTML=nt(l.html),h.appendChild(y),(null==l?void 0:l.urlToGo)&&"string"==typeof l.urlToGo&&""!==l.urlToGo.trim()){var b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("width","16"),b.setAttribute("height","17"),b.setAttribute("viewBox","0 0 16 17"),b.setAttribute("fill","none"),b.setAttribute("xmlns","http://www.w3.org/2000/svg"),Object.assign(b.style,{flexShrink:"0",color:I((null==l?void 0:l.messageBubbleBg)||"#ffffff")});var w=document.createElementNS("http://www.w3.org/2000/svg","g");w.setAttribute("id","External_Link");var E=document.createElementNS("http://www.w3.org/2000/svg","path");E.setAttribute("id","Vector"),E.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"),E.setAttribute("stroke","currentColor"),E.setAttribute("stroke-width","1.5"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round"),w.appendChild(E),b.appendChild(w),h.appendChild(b)}if(s.appendChild(h),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{Y({message_id:l.messageId,content_string:l.html||null,content_id:l.contentId||null}),g.config.toggleIframe(),g.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)L.appendChild(s);else{L.insertBefore(s,L.firstChild);var T=null===(r=g.proactiveElement)||void 0===r?void 0:r.children[1];if(T&&"visible"===T.style.visibility){var x=L.children.length,A=x>0?10*(x-1):0;T.style.animationDelay="".concat(A,"ms")}}W++}))}),t);g.delayTimers.push(o)}))}else if(this.proactiveElement&&this.proactiveElement.parentElement){var j=this.proactiveElement.children[0],G="Right"===(this.config.position||(null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.position)||"Right");Array.from(j.children).forEach((function(e){e.className=G?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){g.proactiveElement&&g.proactiveElement.parentElement&&g.proactiveElement.parentElement.removeChild(g.proactiveElement),g.proactiveElement=null,g.clearProactiveDelays()}),400)}else this.proactiveElement=null,this.clearProactiveDelays()},e}(),Qt=function(){function e(e){var t=this;this.isInitialized=!1,this.hasRegistered=!1,this.isAppReady=!1,this.shouldWaitForAppReady=!1,this.hasPendingOpenRequest=!1,this.overridesPayloadCache=null,this.proactiveDataSentInRegistration=!1,this.openedDueToProactive=!1,this.handleMessage=function(e){var n,i,o,r,a,l,s,c,d,u,p=O().copilotUrl;if(e.origin===p){var f=JSON.parse(e.data);if("APP_READY"===(null==f?void 0:f.type))return t.isAppReady=!0,void t.sendOpenAndRegisterIfReady();if("CHATBOT_CLOSED"===(null==f?void 0:f.type))return void(null===(n=null==t?void 0:t.config)||void 0===n||n.onClose());if("CHATBOT_TOKEN_EXHAUSTED"===(null==f?void 0:f.type))return void t.config.onInternalEvent(S.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null==f?void 0:f.type)&&(null===(o=(i=t.config).onEvent)||void 0===o||o.call(i,{type:A.CHATBOT_LOADED,timestamp:Date.now()}),t.config.onInternalEvent(A.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null==f?void 0:f.type)&&(null===(a=(r=t.config).onEvent)||void 0===a||a.call(r,{type:A.CHAT_INITIALIZED,timestamp:Date.now()}),t.config.onInternalEvent(A.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null==f?void 0:f.type)&&(null===(s=(l=t.config).onEvent)||void 0===s||s.call(l,{type:A.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),t.config.onInternalEvent(A.CHAT_INITIALIZATION_FAILED,{error:null===(c=e.data)||void 0===c?void 0:c.error})),"SESSION_REFRESHED"===(null==f?void 0:f.type)&&(null===(u=(d=t.config).onEvent)||void 0===u||u.call(d,{type:A.SESSION_REFRESHED,timestamp:Date.now()}),t.config.onInternalEvent(A.SESSION_REFRESHED)),"CHAT_MOVED"===(null==f?void 0:f.type)&&t.config.onInternalEvent(S.CHAT_MOVED,{from:e.data.from,to:e.data.to,trigger:e.data.trigger})}},this.config=e,this.iframeElement=document.createElement("iframe"),this.iframeElement.id="chat-iframe-rbyln",this.resizeHandler=this.applyResponsiveStyles.bind(this),this.render(),this.initialize(),this.setupEventListeners()}return e.prototype.getElement=function(){return this.iframeElement},e.prototype.render=function(){var e,t=this.config.position||(null===(e=this.config.config.interface_properties)||void 0===e?void 0:e.position)||"Right";Object.assign(this.iframeElement.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(t.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),this.applyResponsiveStyles()},e.prototype.applyResponsiveStyles=function(){var e,t,n,i,o,r;if(this.iframeElement){var a=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",l=null!==(r=null!==(i=this.config.bottomSpacing)&&void 0!==i?i:null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.bottom_spacing)&&void 0!==r?r:20;window.innerWidth<560?Object.assign(this.iframeElement.style,((e={width:"100vw",minWidth:"300px"})[a.toLowerCase()]="0",e.bottom="0",e.height="100vh",e.flexDirection="column",e.flexGrow="1",e.borderRadius="0",e.top="0",e.maxHeight="100%",e.position="fixed",e)):Object.assign(this.iframeElement.style,((t={width:"26%",minWidth:"400px",height:"calc(100vh - 2rem - 10vh - ".concat(l,"px)"),borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"50rem",position:""})[a.toLowerCase()]=void 0,t))}},e.prototype.initialize=function(){var e=this;if(!this.isInitialized){var t=O().copilotUrl;this.iframeElement.src="".concat(t,"/chatbot-plugin?id=").concat(this.config.config.chatbotId),this.isInitialized=!0,this.iframeElement.addEventListener("load",(function(){var n,i,o,r,a,l,s,c,d,u,p,f,m,v,h,g,_,b,w,E,I,T,x,S,C,O,R,D,N,L,k,M,z,F=new URL(e.iframeElement.src).origin||t;if(null===(n=e.iframeElement.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"},F),e.config.overrides){var P={header_avatar:null!==(r=null===(o=e.config.overrides)||void 0===o?void 0:o.header_avatar)&&void 0!==r?r:null,agent_avatar:null!==(l=null===(a=e.config.overrides)||void 0===a?void 0:a.agent_avatar)&&void 0!==l?l:null,header_title:null!==(c=null===(s=e.config.overrides)||void 0===s?void 0:s.header_title)&&void 0!==c?c:null,header_subtitle:null!==(u=null===(d=e.config.overrides)||void 0===d?void 0:d.header_subtitle)&&void 0!==u?u:null,header_title_text_color:null!==(f=null===(p=e.config.overrides)||void 0===p?void 0:p.header_title_text_color)&&void 0!==f?f:null,header_subtitle_text_color:null!==(v=null===(m=e.config.overrides)||void 0===m?void 0:m.header_subtitle_text_color)&&void 0!==v?v:null,header_bg:null!==(g=null===(h=e.config.overrides)||void 0===h?void 0:h.header_bg)&&void 0!==g?g:null};null===(_=e.iframeElement.contentWindow)||void 0===_||_.postMessage({domain:null===(b=null===window||void 0===window?void 0:window.location)||void 0===b?void 0:b.hostname,action:ut.UPDATE_OVERRIDES,data:P},t)}if(!e.hasRegistered&&e.iframeElement.contentWindow){e.iframeElement.contentWindow.postMessage({domain:null===(w=null===window||void 0===window?void 0:window.location)||void 0===w?void 0:w.hostname,action:ut.I_CAN_AUTHENTICATE,data:{show_history:null===(E=e.config.config)||void 0===E?void 0:E.show_history}},t);var H=X();e.proactiveDataSentInRegistration=!!H,e.iframeElement.contentWindow.postMessage({domain:null===(I=null===window||void 0===window?void 0:window.location)||void 0===I?void 0:I.hostname,action:ut.I_LOADED_LAUNCHER,data:y(y({ws_url:null===(T=e.config.config)||void 0===T?void 0:T.ws_url,userId:null===(x=e.config.config)||void 0===x?void 0:x.userId,token:null===(S=e.config.config)||void 0===S?void 0:S.token,userProfile:y(y({},null===(C=e.config.config)||void 0===C?void 0:C.userProfile),{__INT_SYS_INFO__:y(y({},(null===(R=null===(O=e.config.config)||void 0===O?void 0:O.userProfile)||void 0===R?void 0:R.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null===(D=e.config.config)||void 0===D?void 0:D.isAnonymous},H?{proactiveData:H}:{}),{show_history:null===(N=e.config.config)||void 0===N?void 0:N.show_history})},t),e.hasRegistered=!0}null===(k=(L=e.config).onIframeLoaded)||void 0===k||k.call(L),null===(z=(M=e.config).onEvent)||void 0===z||z.call(M,{type:A.CHATBOT_READY,timestamp:Date.now()}),e.config.onInternalEvent(A.CHATBOT_LOADED)}))}},e.prototype.setupEventListeners=function(){var e=this;window.addEventListener("resize",this.resizeHandler),this.iframeElement.addEventListener("error",(function(){vt.trackError(new Error(Dt[Tt]({src:e.iframeElement.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:Tt,errorType:Ot,context:{config:e.config.config,iframeUrl:e.iframeElement.src,timestamp:Date.now()}})})),window.addEventListener("message",this.handleMessage);window.addEventListener("rblyn:proactiveClick",(function(t){var n,i,o,r,a,l,s,c,d,u;if(e.hasRegistered)if(e.proactiveDataSentInRegistration)e.proactiveDataSentInRegistration=!1;else{e.openedDueToProactive=!0;var p=(null==t?void 0:t.detail)||{},f=O().copilotUrl,m=new URL(e.iframeElement.src).origin||f;null===(n=e.iframeElement.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,action:ut.I_CLICKED_PROACTIVE_BUBBLE,data:{userId:null===(o=e.config.config)||void 0===o?void 0:o.userId,token:null===(r=e.config.config)||void 0===r?void 0:r.token,userProfile:y(y({},null===(a=e.config.config)||void 0===a?void 0:a.userProfile),{__INT_SYS_INFO__:y(y({},(null===(s=null===(l=e.config.config)||void 0===l?void 0:l.userProfile)||void 0===s?void 0:s.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null===(c=e.config.config)||void 0===c?void 0:c.isAnonymous,ws_url:null===(d=e.config.config)||void 0===d?void 0:d.ws_url,proactiveData:{input_id:null,message_id:(null==p?void 0:p.message_id)||null,content_string:(null==p?void 0:p.content_string)||null,content_id:(null==p?void 0:p.content_id)||null},show_history:null===(u=e.config.config)||void 0===u?void 0:u.show_history}},m)}}))},e.prototype.updateVisibility=function(e,t){var n;this.shouldWaitForAppReady=!!t,this.config.isVisible=e;var i=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right";if(e?this.showIframe(i):this.hideIframe(i),!e)return this.openedDueToProactive=!1,void(this.hasPendingOpenRequest=!1);this.hasPendingOpenRequest=!0,this.shouldWaitForAppReady,this.sendOpenAndRegisterIfReady()},e.prototype.showIframe=function(e){this.iframeElement.style.display="block",this.iframeElement.getBoundingClientRect(),this.iframeElement.style.opacity="1",this.iframeElement.style.transform="scale(1) translate3d(0,0,0)"},e.prototype.hideIframe=function(e){var t=this;this.iframeElement.style.opacity="0",this.iframeElement.style.transform="scale(0.3) translate3d(".concat((e.toLowerCase(),"0"),",40px,0)"),setTimeout((function(){t.config.isVisible||(t.iframeElement.style.display="none")}),200)},e.prototype.sendOpenAndRegisterIfReady=function(){var e,t,n,i,o,r,a,l,s,c,d,u;if(this.iframeElement.contentWindow&&this.config.isVisible&&(!this.shouldWaitForAppReady||this.isAppReady)&&this.hasPendingOpenRequest){var p=O().copilotUrl,f=new URL(this.iframeElement.src).origin||p;if(this.iframeElement.contentWindow.postMessage({domain:null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.hostname,name:"openFrame"},f),this.openedDueToProactive)this.openedDueToProactive=!1;else{var m=X();this.iframeElement.contentWindow.postMessage({domain:null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.hostname,action:ut.I_OPENED_IFRAME,data:y(y({ws_url:null===(n=this.config.config)||void 0===n?void 0:n.ws_url,userId:null===(i=this.config.config)||void 0===i?void 0:i.userId,token:null===(o=this.config.config)||void 0===o?void 0:o.token,userProfile:y(y({},null===(r=this.config.config)||void 0===r?void 0:r.userProfile),{__INT_SYS_INFO__:y(y({},(null===(l=null===(a=this.config.config)||void 0===a?void 0:a.userProfile)||void 0===l?void 0:l.__INT_SYS_INFO__)||{}),Lt())}),isAnonymous:null===(s=this.config.config)||void 0===s?void 0:s.isAnonymous},m?{proactiveData:m}:{}),{show_history:null===(c=this.config.config)||void 0===c?void 0:c.show_history})},p)}null===(u=(d=this.config).onEvent)||void 0===u||u.call(d,{type:A.CHATBOT_OPENED,timestamp:Date.now()}),this.config.onInternalEvent(A.CHATBOT_OPENED),this.hasPendingOpenRequest=!1}},e.prototype.update=function(e,t){var n,i,o=this.config.isVisible;if(this.config=y(y({},this.config),e),o!==this.config.isVisible&&this.updateVisibility(this.config.isVisible,t),this.iframeElement.contentWindow&&this.config.isVisible){var r=O().copilotUrl;this.iframeElement.contentWindow.postMessage({action:ut.UPDATE_USER_PROFILE,user_profile:this.config.config.userProfile,show_history:null===(n=this.config.config)||void 0===n?void 0:n.show_history},r),this.iframeElement.contentWindow.postMessage({action:ut.OPENED_IFRAME_EVENT,user_profile:this.config.config.userProfile,show_history:null===(i=this.config.config)||void 0===i?void 0:i.show_history},r)}},e.prototype.destroy=function(){window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("message",this.handleMessage),this.iframeElement&&this.iframeElement.parentNode&&this.iframeElement.parentNode.removeChild(this.iframeElement)},e}(),$t=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,c=(null===window||void 0===window?void 0:window.innerWidth)<560,d=this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right",u=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,p=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 f={position:"fixed",zIndex:"1000",display:"flex",flexDirection:"column"},m=y(y({},f),((e={bottom:"".concat(p,"px")})[d.toLowerCase()]="".concat(u,"px"),e.alignItems="Right"===d?"flex-end":"flex-start",e)),v=y(y({},f),((t={top:"0"})[d.toLowerCase()]="".concat(u,"px"),t.alignItems="center",t));Object.assign(this.containerElement.style,c?v:m)},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}(),en=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){}}},tn=function(){function e(e){var t=this;this.container=null,this.floatingButton=null,this.launcherDelayTimeout=null,this.iframe=null,this.isDestroyed=!1,this.isIframeLoaded=!1,this.handleStateChange=function(e){var n,i,o,r,a,l;if(!t.isDestroyed){var s=e.isInitialized,c=e.error,d=e.chatbotConfig,u=e.isIframeVisible;if(!c&&d&&s){if(t.eventEmitter=en({api_key:t.config.api_key,user_profile:t.config.user_profile,onEvent:t.config.onEvent,chatbotConfig:{isAnonymous:d.isAnonymous,userId:d.userId}}),t.container||(t.container=new $t(d,t.config.position,t.config.sideSpacing,t.config.bottomSpacing)),t.iframe)t.iframe.update({config:d,isVisible:u,position:t.config.position,bottomSpacing:t.config.bottomSpacing,overrides:t.config.overrides},!0);else if(t.iframe=new Qt({config:d,isVisible:u,onClose:t.handleClose,onEvent:t.config.onEvent,onIframeLoaded:function(){t.isIframeLoaded=!0;var e=t.stateManager.getState();t.handleStateChange({isInitialized:e.isInitialized,error:e.error,chatbotConfig:e.chatbotConfig,isIframeVisible:e.isIframeVisible})},onInternalEvent:t.eventEmitter.onInternalEvent,position:t.config.position,bottomSpacing:t.config.bottomSpacing,overrides:t.config.overrides}),t.iframe.getElement&&"function"==typeof t.iframe.getElement){var p=t.iframe.getElement();p&&t.container&&t.container.getElement().prepend(p)}var f=void 0!==t.config.show_launcher?Boolean(t.config.show_launcher):null===(n=null==d?void 0:d.show_launcher)||void 0===n||n,m=!0===(null===(i=null==d?void 0:d.launcher_delay)||void 0===i?void 0:i.enabled),v=null!==(l=null!==(r=null===(o=null==d?void 0:d.launcher_delay)||void 0===o?void 0:o.seconds)&&void 0!==r?r:null===(a=null==d?void 0:d.launcher_delay)||void 0===a?void 0:a.delay)&&void 0!==l?l:0,h=function(){if(t.isIframeLoaded)if(t.floatingButton)t.floatingButton.update({config:d,isIframeVisible:u,position:t.config.position,sideSpacing:t.config.sideSpacing,bottomSpacing:t.config.bottomSpacing,launcher_size:t.config.launcher_size});else if(t.floatingButton=new qt({config:d,toggleIframe:t.toggleIframe,isIframeVisible:u,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),f?m&&Number(v)>0&&!t.floatingButton?t.launcherDelayTimeout=window.setTimeout((function(){t.isIframeLoaded&&h(),t.launcherDelayTimeout=null}),1e3*Number(v)):t.isIframeLoaded&&h():t.floatingButton&&(t.floatingButton.destroy(),t.floatingButton=null)}}},this.toggleIframe=function(){var e=t.stateManager.getState();t.stateManager.toggleIframeVisibility(),t.eventEmitter.emit(e.isIframeVisible?A.CHATBOT_CLOSED:A.CHATBOT_BUTTON_CLICKED)},this.handleClose=function(){t.stateManager.closeIframe(),t.eventEmitter.emit(A.CHATBOT_CLOSED)};var n=y(y({},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 vt.trackError(new Error(Dt[ht](e.api_key)),"RobylonChatbot",{errorCode:ht,errorType:St,context:{timestamp:Date.now()}}),new Error("API key is required");try{vt.initialize(e.api_key,e.user_id)}catch(e){vt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:bt,errorType:St,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=y(y({},t),e),n.forEach((function(e){return e(t)}))};return{getState:function(){return t},initialize:function(){return b(void 0,void 0,void 0,(function(){var t,n,o;return w(this,(function(r){switch(r.label){case 0:if(!e.api_key)return vt.trackError(new Error(Dt[ht](e.api_key)),"ChatbotStateManager",{errorCode:ht,errorType:St,context:{timestamp:Date.now()}}),[2];i({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Gt(e)];case 2:return t=r.sent(),[4,new Promise((function(e,n){Wt(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}),vt.trackError(n instanceof Error?n:new Error(o),"ChatbotStateManager",{errorCode:yt,errorType:St,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=en({api_key:e.api_key,user_profile:e.user_profile,onEvent:e.onEvent,chatbotConfig:null}),this.initialize()}return e.prototype.initialize=function(){return b(this,void 0,void 0,(function(){var e;return w(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(),vt.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot.initialize",{errorCode:yt,errorType:St,context:{timestamp:Date.now()}}),[3,3];case 3:return[2]}}))}))},e.prototype.show=function(){this.stateManager.getState().isIframeVisible||(this.stateManager.toggleIframeVisibility(),this.eventEmitter.emit(A.CHATBOT_BUTTON_CLICKED))},e.prototype.hide=function(){this.stateManager.getState().isIframeVisible&&(this.stateManager.closeIframe(),this.eventEmitter.emit(A.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.iframe&&(this.iframe.destroy(),this.iframe=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 nn(e){return new tn(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=nn(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=nn(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 on=window,rn=null==on?void 0:on.RobylonChatbot;rn&&!(null==on?void 0:on.R)&&(on.R=rn)}var an={create:nn,getState:function(){return"initialized"}};export{Jt as Chatbot,u as ChatbotInterfaceType,g as ConditionType,v as DisplayAttributesType,f as LauncherType,h as LogicalConditionType,_ as MessageDisplayType,m as ProactiveSendTimeType,an as RobylonChatbot,p as WidgetPositionEnums,Zt as useChatbot};
3
+ const{entries:Z,setPrototypeOf:Q,isFrozen:$,getPrototypeOf:ee,getOwnPropertyDescriptor:ne}=Object;let{freeze:te,seal:oe,create:ie}=Object,{apply:re,construct:le}="undefined"!=typeof Reflect&&Reflect;te||(te=function(e){return e}),oe||(oe=function(e){return e}),re||(re=function(e,n){for(var t=arguments.length,o=new Array(t>2?t-2:0),i=2;i<t;i++)o[i-2]=arguments[i];return e.apply(n,o)}),le||(le=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),o=1;o<n;o++)t[o-1]=arguments[o];return new e(...t)});const ae=Ee(Array.prototype.forEach),se=Ee(Array.prototype.lastIndexOf),ce=Ee(Array.prototype.pop),de=Ee(Array.prototype.push),ue=Ee(Array.prototype.splice),pe=Ee(String.prototype.toLowerCase),fe=Ee(String.prototype.toString),he=Ee(String.prototype.match),ve=Ee(String.prototype.replace),me=Ee(String.prototype.indexOf),ge=Ee(String.prototype.trim),_e=Ee(Object.prototype.hasOwnProperty),be=Ee(RegExp.prototype.test),ye=(we=TypeError,function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return le(we,n)});var we;function Ee(e){return function(n){n instanceof RegExp&&(n.lastIndex=0);for(var t=arguments.length,o=new Array(t>1?t-1:0),i=1;i<t;i++)o[i-1]=arguments[i];return re(e,n,o)}}function Ie(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:pe;Q&&Q(e,null);let o=n.length;for(;o--;){let i=n[o];if("string"==typeof i){const e=t(i);e!==i&&($(n)||(n[o]=e),i=e)}e[i]=!0}return e}function Te(e){for(let n=0;n<e.length;n++){_e(e,n)||(e[n]=null)}return e}function Se(e){const n=ie(null);for(const[t,o]of Z(e)){_e(e,t)&&(Array.isArray(o)?n[t]=Te(o):o&&"object"==typeof o&&o.constructor===Object?n[t]=Se(o):n[t]=o)}return n}function xe(e,n){for(;null!==e;){const t=ne(e,n);if(t){if(t.get)return Ee(t.get);if("function"==typeof t.value)return Ee(t.value)}e=ee(e)}return function(){return null}}const Ae=te(["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"]),Ce=te(["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"]),Oe=te(["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"]),De=te(["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"]),Re=te(["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"]),Ne=te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Le=te(["#text"]),ke=te(["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"]),Me=te(["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"]),ze=te(["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"]),Pe=te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),He=oe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Fe=oe(/<%[\w\W]*|[\w\W]*%>/gm),Ue=oe(/\$\{[\w\W]*/gm),Be=oe(/^data-[\-\w.\u00B7-\uFFFF]+$/),We=oe(/^aria-[\-\w]+$/),je=oe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ve=oe(/^(?:\w+script|data):/i),Ge=oe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ye=oe(/^html$/i),Ke=oe(/^[a-z][.\w]*(-[.\w]+)+$/i);var Xe=Object.freeze({__proto__:null,ARIA_ATTR:We,ATTR_WHITESPACE:Ge,CUSTOM_ELEMENT:Ke,DATA_ATTR:Be,DOCTYPE_NAME:Ye,ERB_EXPR:Fe,IS_ALLOWED_URI:je,IS_SCRIPT_OR_DATA:Ve,MUSTACHE_EXPR:He,TMPLIT_EXPR:Ue});const qe=1,Je=3,Ze=7,Qe=8,$e=9,en=function(){return"undefined"==typeof window?null:window};var nn=function e(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:en();const t=n=>e(n);if(t.version="3.3.0",t.removed=[],!n||!n.document||n.document.nodeType!==$e||!n.Element)return t.isSupported=!1,t;let{document:o}=n;const i=o,r=i.currentScript,{DocumentFragment:l,HTMLTemplateElement:a,Node:s,Element:c,NodeFilter:d,NamedNodeMap:u=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:p,DOMParser:f,trustedTypes:h}=n,v=c.prototype,m=xe(v,"cloneNode"),g=xe(v,"remove"),_=xe(v,"nextSibling"),b=xe(v,"childNodes"),y=xe(v,"parentNode");if("function"==typeof a){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let w,E="";const{implementation:I,createNodeIterator:T,createDocumentFragment:S,getElementsByTagName:x}=o,{importNode:A}=i;let C={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};t.isSupported="function"==typeof Z&&"function"==typeof y&&I&&void 0!==I.createHTMLDocument;const{MUSTACHE_EXPR:O,ERB_EXPR:D,TMPLIT_EXPR:R,DATA_ATTR:N,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:k,ATTR_WHITESPACE:M,CUSTOM_ELEMENT:z}=Xe;let{IS_ALLOWED_URI:P}=Xe,H=null;const F=Ie({},[...Ae,...Ce,...Oe,...Re,...Le]);let U=null;const B=Ie({},[...ke,...Me,...ze,...Pe]);let W=Object.seal(ie(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}})),j=null,V=null;const G=Object.seal(ie(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Y=!0,K=!0,X=!1,q=!0,J=!1,Q=!0,$=!1,ee=!1,ne=!1,oe=!1,re=!1,le=!1,we=!0,Ee=!1,Te=!0,He=!1,Fe={},Ue=null;const Be=Ie({},["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 We=null;const Ve=Ie({},["audio","video","img","source","image","track"]);let Ge=null;const Ke=Ie({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),nn="http://www.w3.org/1998/Math/MathML",tn="http://www.w3.org/2000/svg",on="http://www.w3.org/1999/xhtml";let rn=on,ln=!1,an=null;const sn=Ie({},[nn,tn,on],fe);let cn=Ie({},["mi","mo","mn","ms","mtext"]),dn=Ie({},["annotation-xml"]);const un=Ie({},["title","style","font","a","script"]);let pn=null;const fn=["application/xhtml+xml","text/html"];let hn=null,vn=null;const mn=o.createElement("form"),gn=function(e){return e instanceof RegExp||e instanceof Function},_n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!vn||vn!==e){if(e&&"object"==typeof e||(e={}),e=Se(e),pn=-1===fn.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,hn="application/xhtml+xml"===pn?fe:pe,H=_e(e,"ALLOWED_TAGS")?Ie({},e.ALLOWED_TAGS,hn):F,U=_e(e,"ALLOWED_ATTR")?Ie({},e.ALLOWED_ATTR,hn):B,an=_e(e,"ALLOWED_NAMESPACES")?Ie({},e.ALLOWED_NAMESPACES,fe):sn,Ge=_e(e,"ADD_URI_SAFE_ATTR")?Ie(Se(Ke),e.ADD_URI_SAFE_ATTR,hn):Ke,We=_e(e,"ADD_DATA_URI_TAGS")?Ie(Se(Ve),e.ADD_DATA_URI_TAGS,hn):Ve,Ue=_e(e,"FORBID_CONTENTS")?Ie({},e.FORBID_CONTENTS,hn):Be,j=_e(e,"FORBID_TAGS")?Ie({},e.FORBID_TAGS,hn):Se({}),V=_e(e,"FORBID_ATTR")?Ie({},e.FORBID_ATTR,hn):Se({}),Fe=!!_e(e,"USE_PROFILES")&&e.USE_PROFILES,Y=!1!==e.ALLOW_ARIA_ATTR,K=!1!==e.ALLOW_DATA_ATTR,X=e.ALLOW_UNKNOWN_PROTOCOLS||!1,q=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,J=e.SAFE_FOR_TEMPLATES||!1,Q=!1!==e.SAFE_FOR_XML,$=e.WHOLE_DOCUMENT||!1,oe=e.RETURN_DOM||!1,re=e.RETURN_DOM_FRAGMENT||!1,le=e.RETURN_TRUSTED_TYPE||!1,ne=e.FORCE_BODY||!1,we=!1!==e.SANITIZE_DOM,Ee=e.SANITIZE_NAMED_PROPS||!1,Te=!1!==e.KEEP_CONTENT,He=e.IN_PLACE||!1,P=e.ALLOWED_URI_REGEXP||je,rn=e.NAMESPACE||on,cn=e.MATHML_TEXT_INTEGRATION_POINTS||cn,dn=e.HTML_INTEGRATION_POINTS||dn,W=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&gn(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(W.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&gn(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(W.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(W.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),J&&(K=!1),re&&(oe=!0),Fe&&(H=Ie({},Le),U=[],!0===Fe.html&&(Ie(H,Ae),Ie(U,ke)),!0===Fe.svg&&(Ie(H,Ce),Ie(U,Me),Ie(U,Pe)),!0===Fe.svgFilters&&(Ie(H,Oe),Ie(U,Me),Ie(U,Pe)),!0===Fe.mathMl&&(Ie(H,Re),Ie(U,ze),Ie(U,Pe))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?G.tagCheck=e.ADD_TAGS:(H===F&&(H=Se(H)),Ie(H,e.ADD_TAGS,hn))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?G.attributeCheck=e.ADD_ATTR:(U===B&&(U=Se(U)),Ie(U,e.ADD_ATTR,hn))),e.ADD_URI_SAFE_ATTR&&Ie(Ge,e.ADD_URI_SAFE_ATTR,hn),e.FORBID_CONTENTS&&(Ue===Be&&(Ue=Se(Ue)),Ie(Ue,e.FORBID_CONTENTS,hn)),Te&&(H["#text"]=!0),$&&Ie(H,["html","head","body"]),H.table&&(Ie(H,["tbody"]),delete j.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ye('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ye('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=e.TRUSTED_TYPES_POLICY,E=w.createHTML("")}else void 0===w&&(w=function(e,n){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let t=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(t=n.getAttribute(o));const i="dompurify"+(t?"#"+t:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}}(h,r)),null!==w&&"string"==typeof E&&(E=w.createHTML(""));te&&te(e),vn=e}},bn=Ie({},[...Ce,...Oe,...De]),yn=Ie({},[...Re,...Ne]),wn=function(e){de(t.removed,{element:e});try{y(e).removeChild(e)}catch(n){g(e)}},En=function(e,n){try{de(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch(e){de(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),"is"===e)if(oe||re)try{wn(n)}catch(e){}else try{n.setAttribute(e,"")}catch(e){}},In=function(e){let n=null,t=null;if(ne)e="<remove></remove>"+e;else{const n=he(e,/^[\r\n\t ]+/);t=n&&n[0]}"application/xhtml+xml"===pn&&rn===on&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const i=w?w.createHTML(e):e;if(rn===on)try{n=(new f).parseFromString(i,pn)}catch(e){}if(!n||!n.documentElement){n=I.createDocument(rn,"template",null);try{n.documentElement.innerHTML=ln?E:i}catch(e){}}const r=n.body||n.documentElement;return e&&t&&r.insertBefore(o.createTextNode(t),r.childNodes[0]||null),rn===on?x.call(n,$?"html":"body")[0]:$?n.documentElement:r},Tn=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)},Sn=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)},xn=function(e){return"function"==typeof s&&e instanceof s};function An(e,n,o){ae(e,(e=>{e.call(t,n,o,vn)}))}const Cn=function(e){let n=null;if(An(C.beforeSanitizeElements,e,null),Sn(e))return wn(e),!0;const o=hn(e.nodeName);if(An(C.uponSanitizeElement,e,{tagName:o,allowedTags:H}),Q&&e.hasChildNodes()&&!xn(e.firstElementChild)&&be(/<[/\w!]/g,e.innerHTML)&&be(/<[/\w!]/g,e.textContent))return wn(e),!0;if(e.nodeType===Ze)return wn(e),!0;if(Q&&e.nodeType===Qe&&be(/<[/\w]/g,e.data))return wn(e),!0;if(!(G.tagCheck instanceof Function&&G.tagCheck(o))&&(!H[o]||j[o])){if(!j[o]&&Dn(o)){if(W.tagNameCheck instanceof RegExp&&be(W.tagNameCheck,o))return!1;if(W.tagNameCheck instanceof Function&&W.tagNameCheck(o))return!1}if(Te&&!Ue[o]){const n=y(e)||e.parentNode,t=b(e)||e.childNodes;if(t&&n){for(let o=t.length-1;o>=0;--o){const i=m(t[o],!0);i.__removalCount=(e.__removalCount||0)+1,n.insertBefore(i,_(e))}}}return wn(e),!0}return e instanceof c&&!function(e){let n=y(e);n&&n.tagName||(n={namespaceURI:rn,tagName:"template"});const t=pe(e.tagName),o=pe(n.tagName);return!!an[e.namespaceURI]&&(e.namespaceURI===tn?n.namespaceURI===on?"svg"===t:n.namespaceURI===nn?"svg"===t&&("annotation-xml"===o||cn[o]):Boolean(bn[t]):e.namespaceURI===nn?n.namespaceURI===on?"math"===t:n.namespaceURI===tn?"math"===t&&dn[o]:Boolean(yn[t]):e.namespaceURI===on?!(n.namespaceURI===tn&&!dn[o])&&!(n.namespaceURI===nn&&!cn[o])&&!yn[t]&&(un[t]||!bn[t]):!("application/xhtml+xml"!==pn||!an[e.namespaceURI]))}(e)?(wn(e),!0):"noscript"!==o&&"noembed"!==o&&"noframes"!==o||!be(/<\/no(script|embed|frames)/i,e.innerHTML)?(J&&e.nodeType===Je&&(n=e.textContent,ae([O,D,R],(e=>{n=ve(n,e," ")})),e.textContent!==n&&(de(t.removed,{element:e.cloneNode()}),e.textContent=n)),An(C.afterSanitizeElements,e,null),!1):(wn(e),!0)},On=function(e,n,t){if(we&&("id"===n||"name"===n)&&(t in o||t in mn))return!1;if(K&&!V[n]&&be(N,n));else if(Y&&be(L,n));else if(G.attributeCheck instanceof Function&&G.attributeCheck(n,e));else if(!U[n]||V[n]){if(!(Dn(e)&&(W.tagNameCheck instanceof RegExp&&be(W.tagNameCheck,e)||W.tagNameCheck instanceof Function&&W.tagNameCheck(e))&&(W.attributeNameCheck instanceof RegExp&&be(W.attributeNameCheck,n)||W.attributeNameCheck instanceof Function&&W.attributeNameCheck(n,e))||"is"===n&&W.allowCustomizedBuiltInElements&&(W.tagNameCheck instanceof RegExp&&be(W.tagNameCheck,t)||W.tagNameCheck instanceof Function&&W.tagNameCheck(t))))return!1}else if(Ge[n]);else if(be(P,ve(t,M,"")));else if("src"!==n&&"xlink:href"!==n&&"href"!==n||"script"===e||0!==me(t,"data:")||!We[e]){if(X&&!be(k,ve(t,M,"")));else if(t)return!1}else;return!0},Dn=function(e){return"annotation-xml"!==e&&he(e,z)},Rn=function(e){An(C.beforeSanitizeAttributes,e,null);const{attributes:n}=e;if(!n||Sn(e))return;const o={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:U,forceKeepAttr:void 0};let i=n.length;for(;i--;){const r=n[i],{name:l,namespaceURI:a,value:s}=r,c=hn(l),d=s;let u="value"===l?d:ge(d);if(o.attrName=c,o.attrValue=u,o.keepAttr=!0,o.forceKeepAttr=void 0,An(C.uponSanitizeAttribute,e,o),u=o.attrValue,!Ee||"id"!==c&&"name"!==c||(En(l,e),u="user-content-"+u),Q&&be(/((--!?|])>)|<\/(style|title|textarea)/i,u)){En(l,e);continue}if("attributename"===c&&he(u,"href")){En(l,e);continue}if(o.forceKeepAttr)continue;if(!o.keepAttr){En(l,e);continue}if(!q&&be(/\/>/i,u)){En(l,e);continue}J&&ae([O,D,R],(e=>{u=ve(u,e," ")}));const p=hn(e.nodeName);if(On(p,c,u)){if(w&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(a);else switch(h.getAttributeType(p,c)){case"TrustedHTML":u=w.createHTML(u);break;case"TrustedScriptURL":u=w.createScriptURL(u)}if(u!==d)try{a?e.setAttributeNS(a,l,u):e.setAttribute(l,u),Sn(e)?wn(e):ce(t.removed)}catch(n){En(l,e)}}else En(l,e)}An(C.afterSanitizeAttributes,e,null)},Nn=function e(n){let t=null;const o=Tn(n);for(An(C.beforeSanitizeShadowDOM,n,null);t=o.nextNode();)An(C.uponSanitizeShadowNode,t,null),Cn(t),Rn(t),t.content instanceof l&&e(t.content);An(C.afterSanitizeShadowDOM,n,null)};return t.sanitize=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,r=null,a=null,c=null;if(ln=!e,ln&&(e="\x3c!--\x3e"),"string"!=typeof e&&!xn(e)){if("function"!=typeof e.toString)throw ye("toString is not a function");if("string"!=typeof(e=e.toString()))throw ye("dirty is not a string, aborting")}if(!t.isSupported)return e;if(ee||_n(n),t.removed=[],"string"==typeof e&&(He=!1),He){if(e.nodeName){const n=hn(e.nodeName);if(!H[n]||j[n])throw ye("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)o=In("\x3c!----\x3e"),r=o.ownerDocument.importNode(e,!0),r.nodeType===qe&&"BODY"===r.nodeName||"HTML"===r.nodeName?o=r:o.appendChild(r);else{if(!oe&&!J&&!$&&-1===e.indexOf("<"))return w&&le?w.createHTML(e):e;if(o=In(e),!o)return oe?null:le?E:""}o&&ne&&wn(o.firstChild);const d=Tn(He?e:o);for(;a=d.nextNode();)Cn(a),Rn(a),a.content instanceof l&&Nn(a.content);if(He)return e;if(oe){if(re)for(c=S.call(o.ownerDocument);o.firstChild;)c.appendChild(o.firstChild);else c=o;return(U.shadowroot||U.shadowrootmode)&&(c=A.call(i,c,!0)),c}let u=$?o.outerHTML:o.innerHTML;return $&&H["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&be(Ye,o.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+u),J&&ae([O,D,R],(e=>{u=ve(u,e," ")})),w&&le?w.createHTML(u):u},t.setConfig=function(){_n(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ee=!0},t.clearConfig=function(){vn=null,ee=!1},t.isValidAttribute=function(e,n,t){vn||_n({});const o=hn(e),i=hn(n);return On(o,i,t)},t.addHook=function(e,n){"function"==typeof n&&de(C[e],n)},t.removeHook=function(e,n){if(void 0!==n){const t=se(C[e],n);return-1===t?void 0:ue(C[e],t,1)[0]}return ce(C[e])},t.removeHooks=function(e){C[e]=[]},t.removeAllHooks=function(){C={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},t}(),tn=function(e){return e?nn.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 on(e){if(!e||"string"!=typeof e||0===e.trim().length)return"ltr";var n=e.replace(/<[^>]*>/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`#]/g,"").trim();if(0===n.length)return"ltr";for(var t=/[\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,o=0,i=0,r=0,l=n;r<l.length;r++){var a=l[r];/\s|\d|[.,;:!?()[\]{}'"`\-_=+*/\\|@#$%^&*~]/.test(a)||(i++,t.test(a)&&o++)}return 0===i?"ltr":o/i>.3?"rtl":"ltr"}var rn,ln=n((function(n){var r,l,a,s,c,d,u,p,h,v,m,g,y,w,S,A,C,D,L,k,M=n.config,z=n.toggleIframe,P=n.isIframeVisible,H=n.onEvent,U=n.onInternalEvent,B=n.position,W=n.sideSpacing,j=n.bottomSpacing,K=n.launcher_type,X=n.launcher_properties_text,q=n.shouldFadeIn,Z=n.launcher_size,Q=t(null),$=O().copilotUrl,ee=o(!1),ne=ee[0],te=ee[1],oe=o(!1),ie=oe[0],re=oe[1],le=o([]),ae=le[0],se=le[1],ce=o(!1),de=ce[0],ue=ce[1],pe=t([]),fe=t(),he=t(new Set),ve=t(new Map),me=t(new Set),ge=null!==(a=null==M?void 0:M.launcher_size_multiplier)&&void 0!==a?a:1,_e=null!=Z?Z:48*ge;i((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;te(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),i((function(){Q.current&&requestAnimationFrame((function(){null==H||H({type:x.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),U(x.CHATBOT_BUTTON_LOADED)}))}),[H,U]),i((function(){if(Q.current&&q){Q.current.style.opacity="0";var e=requestAnimationFrame((function(){Q.current&&(Q.current.style.opacity="1")}));return function(){return cancelAnimationFrame(e)}}}),[q]);var be=(null==M?void 0:M.launcher_type)?(null===(c=null===(s=null==M?void 0:M.images)||void 0===s?void 0:s.launcher_image_url)||void 0===c?void 0:c.url)||"".concat($,"/chatbubble.png"):(null==M?void 0:M.image_url)||"".concat($,"/chatbubble.png"),ye=function(){return e.createElement("div",{style:{position:"relative",width:"100%",height:"100%"}},e.createElement("img",{src:be,alt:"Chat","aria-hidden":P,style:{zIndex:1e3,cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box",position:"absolute",inset:0,opacity:P?0:1}}),P?(n=Math.round(.5*_e),e.createElement("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"}},e.createElement("svg",{width:n,height:n,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"}))))):null);var n},we=B||(null===(d=M.interface_properties)||void 0===d?void 0:d.position)||"Right",Ee=null!==(p=null!=W?W:null===(u=M.interface_properties)||void 0===u?void 0:u.side_spacing)&&void 0!==p?p:20,Ie=null!==(v=null!=j?j:null===(h=M.interface_properties)||void 0===h?void 0:h.bottom_spacing)&&void 0!==v?v:20,Te=K||(null==M?void 0:M.launcher_type)||f.IMAGE,Se=X||(null===(m=null==M?void 0:M.launcher_properties)||void 0===m?void 0:m.text),xe={zIndex:1e3,display:"flex",flexDirection:"column-reverse",alignItems:"center",justifyContent:"center",cursor:"pointer",overflow:"hidden",marginTop:"16px",boxSizing:"border-box"};Te===f.IMAGE&&(xe.width="".concat(_e,"px"),xe.height="".concat(_e,"px"),xe.borderRadius="50%",xe.backgroundColor=M.brand_colour);var Ae=b(b({},xe),((r={position:void 0,bottom:"0",borderRadius:Te===f.IMAGE?"50%":"9999px"})[we.toLowerCase()]="0",r)),Ce=b(b({},xe),((l={position:"fixed",bottom:"".concat(Ie,"px"),borderRadius:Te===f.IMAGE?"50%":"9999px"})[we.toLowerCase()]="".concat(Ee,"px"),l)),Oe=ne?Ce:Ae;i((function(){T.log("Screen width changed, isMobile:",ne,"Style:",Oe)}),[ne,Oe]),T.log("config in floating button",M);i((function(){var e=function(){pe.current.forEach((function(e){return clearTimeout(e)})),pe.current=[]},n=function(){ve.current.forEach((function(e){window.removeEventListener("scroll",e)})),ve.current.clear(),me.current.clear()},t=function(e,n,t){se((function(o){var i=[];return e.forEach((function(e){(n.get(e)||[]).forEach((function(e){var n="".concat(e.messageId,"-").concat(e.contentIndex);if(!o.some((function(n){return n.id===e.messageId&&n.index===e.contentIndex}))){var t={id:e.messageId,index:e.contentIndex,html:e.html,contentId:e.contentId,messageDisplayType:e.messageDisplayType,messageBubbleBg:null==e?void 0:e.messageBubbleBg,urlToGo:null==e?void 0:e.urlToGo};i.push(t),he.current.add(n),setTimeout((function(){he.current.delete(n)}),1200)}}))})),0===t?E(E([],o,!0),i,!0):E(E([],i,!0),o,!0)}))},o=function(){if(e(),n(),se([]),he.current.clear(),(null==M?void 0:M.proactive_message_obj)&&!G()){var o=J(null==M?void 0:M.proactive_message_obj),i=[],r=[];o.forEach((function(e){"scroll"===e.delayType&&void 0!==e.scrollThreshold&&Number(e.scrollThreshold)>0?r.push(e):i.push(e)}));var l=new Map;i.forEach((function(e){var n=l.get(e.delayMs);n||(n={messageIds:[],groups:new Map},l.set(e.delayMs,n)),n.groups.has(e.messageId)||(n.messageIds.push(e.messageId),n.groups.set(e.messageId,[])),n.groups.get(e.messageId).push(e)})),l.forEach((function(e,n){var o=e.messageIds,i=e.groups,r=window.setTimeout((function(){t(o,i,n)}),n);pe.current.push(r)}));var a=new Map;r.forEach((function(e){var n=e.scrollThreshold||0,t=a.get(n);t||(t={messageIds:[],groups:new Map},a.set(n,t)),t.groups.has(e.messageId)||(t.messageIds.push(e.messageId),t.groups.set(e.messageId,[])),t.groups.get(e.messageId).push(e)})),a.forEach((function(e,n){var o=e.messageIds,i=e.groups,r="scroll-".concat(n),l=function(){if((window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=n&&!me.current.has(r)){me.current.add(r),t(o,i,1);var e=ve.current.get(r);e&&(window.removeEventListener("scroll",e),ve.current.delete(r))}};l();var a=l;ve.current.set(r,a),window.addEventListener("scroll",a,{passive:!0})}))}};return fe.current=F((function(){re(!1),o()})),o(),function(){var t;e(),n(),null===(t=fe.current)||void 0===t||t.call(fe)}}),[null==M?void 0:M.proactive_message_obj]);var De=ae.length>0&&!P&&!ie,Re="Right"===(B||(null===(g=M.interface_properties)||void 0===g?void 0:g.position)||"Right"),Ne=function(){ue(!0),setTimeout((function(){re(!0),V(),ue(!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(R,';\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 ')),De?e.createElement("div",{className:"proactive-message-container",style:{position:"fixed",bottom:"".concat((null!==(w=null!=j?j:null===(y=M.interface_properties)||void 0===y?void 0:y.bottom_spacing)&&void 0!==w?w:20)+(Te===f.IMAGE?_e:void 0!==Z?40:40*ge)+8,"px"),right:Re?"".concat(null!==(A=null!=W?W:null===(S=M.interface_properties)||void 0===S?void 0:S.side_spacing)&&void 0!==A?A:20,"px"):"auto",left:Re?"auto":"".concat(null!==(D=null!=W?W:null===(C=M.interface_properties)||void 0===C?void 0:C.side_spacing)&&void 0!==D?D:20,"px"),maxWidth:"22.875rem",zIndex:2147483646}},e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:Re?"flex-end":"flex-start"},className:"proactive-message-bubble-container"},ae.map((function(n,t){var o="".concat(n.id,"-").concat(n.index),i=he.current.has(o),r=10*(ae.length-1-t),l=n.messageDisplayType===_.BUTTON;return console.log("visibleProactives",ae),e.createElement("div",{key:o,onClick:function(){if((null==n?void 0:n.urlToGo)&&"string"==typeof n.urlToGo&&""!==n.urlToGo.trim())window.open(n.urlToGo,"_blank","noopener,noreferrer");else{Y({message_id:n.id,content_string:n.html||null,content_id:n.contentId||null}),z(),Ne();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:n.id,content_string:n.html||null,content_id:n.contentId||null}}))}catch(e){}}},className:de?Re?"proactive-bubble-exit-right":"proactive-bubble-exit-left":i&&!de?Re?"proactive-bubble-enter-right":"proactive-bubble-enter-left":"",style:b({background:(null==n?void 0:n.messageBubbleBg)||"#ffffff",color:"#111",borderRadius:l?"100px":"12px",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.08)",padding:"16px",cursor:"pointer",fontFamily:R,lineHeight:N,fontSize:"14px",marginBottom:t<ae.length-1?16:0,border:"1px solid #F1F2F4",width:"fit-content",maxWidth:"100%",animationDelay:de?"0ms":i?"".concat(r,"ms"):void 0},de?{opacity:0}:i?{opacity:0,transform:Re?"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:on(n.html),dangerouslySetInnerHTML:{__html:tn(n.html)}}),(null==n?void 0:n.urlToGo)&&"string"==typeof n.urlToGo&&""!==n.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:I((null==n?void 0:n.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(),Ne()},className:de?"":Re?"proactive-close-enter-right":"proactive-close-enter-left",style:b({position:"absolute",top:"-32px",right:"Right"===(B||(null===(L=M.interface_properties)||void 0===L?void 0:L.position)||"Right")?"0px":"auto",left:"Left"===(B||(null===(k=M.interface_properties)||void 0===k?void 0:k.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:de?"0ms":"".concat(10*(ae.length-1),"ms")},de?{}:{opacity:0,transform:Re?"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:Q,className:"message-bubble-container",style:b(b({},Oe),{transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 280ms ease",transform:P?"scale(0.85)":"scale(1)",opacity:q?0:1}),onClick:function(){z(),Ne()}},function(){switch(Te){case f.TEXT:return n=void 0!==Z?void 0:160*ge,t=void 0!==Z?void 0:40*ge,o=void 0!==Z?void 0:14*ge,i=void 0!==Z?void 0:21*ge,e.createElement("div",{style:{width:void 0!==n?"".concat(n,"px"):"fit-content",maxWidth:void 0!==n?"".concat(n,"px"):"160px",height:void 0!==t?"".concat(t,"px"):"40px",borderRadius:"9999px",backgroundColor:M.brand_colour,display:"flex",alignItems:"center",padding:"9px 20px",boxShadow:"0px 0px 16px 0px rgba(0, 0, 0, 0.24)",boxSizing:"border-box",fontFamily:R,lineHeight:N}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:on(Se),style:{margin:0,color:I(M.brand_colour),fontSize:void 0!==o?"".concat(o,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:R,lineHeight:void 0!==i?"".concat(i,"px"):N,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},Se)));case f.TEXTUAL_IMAGE:return function(){var n,t,o=void 0!==Z?void 0:174*ge,i=void 0!==Z?void 0:40*ge,r=void 0!==Z?void 0:40*ge,l=void 0!==Z?void 0:14*ge,a=void 0!==Z?void 0:21*ge;return e.createElement("div",{style:{maxWidth:void 0!==o?"".concat(o,"px"):"13rem",width:"fit-content",height:void 0!==i?"".concat(i,"px"):"40px",borderRadius:"9999px",backgroundColor:M.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:R,lineHeight:N}},e.createElement("div",{style:{flex:1,minWidth:0}},e.createElement("p",{dir:on(Se),style:{margin:0,color:I(M.brand_colour),fontSize:void 0!==l?"".concat(l,"px"):"0.875rem",fontWeight:600,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:R,lineHeight:void 0!==a?"".concat(a,"px"):N,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}},Se)),e.createElement("div",{style:{width:void 0!==r?"".concat(r,"px"):"40px",height:void 0!==r?"".concat(r,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:0}},e.createElement("img",{src:(null==M?void 0:M.launcher_type)?(null===(t=null===(n=null==M?void 0:M.images)||void 0===n?void 0:n.launcher_image_url)||void 0===t?void 0:t.url)||"".concat($,"/chatbubble.png"):(null==M?void 0:M.image_url)||"".concat($,"/chatbubble.png"),alt:"Chat",style:{width:"100%",height:"100%",objectFit:"cover"}})))}();case f.IMAGE:default:return ye()}var n,t,o,i}()))})),an=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]},sn=function(){var e;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands)for(var n=["Chrome","Firefox","Safari","Edge","Opera"],t=0,o=navigator.userAgentData.brands;t<o.length;t++){var i=o[t];if(n.includes(i.brand))return i.brand}return(/Chrome|Firefox|Safari|Edge|Opera/.exec(navigator.userAgent)||["Unknown"])[0]},cn=function(){var e,n,t,o;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===(n=null===document||void 0===document?void 0:document.body)||void 0===n?void 0:n.clientWidth),height:(null===window||void 0===window?void 0:window.innerHeight)||(null===(t=null===document||void 0===document?void 0:document.documentElement)||void 0===t?void 0:t.clientHeight)||(null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.clientHeight)}},dn=function(){return{platform:"web",os:an(),browser:sn(),sdk_version:"2.0.0-alpha-staging.9",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:cn()};var e};!function(e){e.ERROR="ERROR",e.INFO="INFO"}(rn||(rn={}));var un,pn,fn=["@robylon/web-react-sdk","node_modules/@robylon/web-react-sdk/"],hn=function(e){var n=e.filename,t=e.stack,o=e.message;return!!(n||t||o)&&fn.some((function(e){return(null==n?void 0:n.includes(e))||(null==t?void 0:t.includes(e))||(null==o?void 0:o.includes(e))}))},vn=function(){function e(){var e=this;this.apiKey="",this.userId=null,this.preInitQueue=[],this.isInitialized=!1,this.handleWindowError=function(n){var t,o={filename:n.filename,stack:null===(t=n.error)||void 0===t?void 0:t.stack,message:n.message};hn(o)&&e.trackError(n.error||n.message,"GlobalErrorHandler",{filename:n.filename,lineNo:n.lineno,colNo:n.colno})},this.handleUnhandledRejection=function(n){var t,o,i={stack:null===(t=n.reason)||void 0===t?void 0:t.stack,message:(null===(o=n.reason)||void 0===o?void 0:o.message)||String(n.reason)};hn(i)&&e.trackError(n.reason||"Unhandled Promise Rejection","GlobalPromiseHandler",{reason:n.reason})},this.setupGlobalHandlers()}return e.prototype.setupGlobalHandlers=function(){C()&&(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(){C()&&(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,n){void 0===n&&(n=null);try{if(this.preInitQueue.length>0){var t={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:n,timestamp:Date.now()},timestamp:Date.now()},metadata:dn(),event_type:rn.ERROR,user_id:n};this.sendLog(t).catch(console.error)}this.apiKey=e,this.userId=n,this.isInitialized=!0,this.processPreInitQueue()}catch(t){T.error("Error during ErrorTrackingService initialization:",t),this.preInitQueue.push({error:t instanceof Error?t:new Error(String(t)),componentName:"ErrorTrackingService",additionalInfo:{apiKey:e,userId:n}})}},e.prototype.processPreInitQueue=function(){return y(this,void 0,void 0,(function(){var e,n,t;return w(this,(function(o){switch(o.label){case 0:if(!this.preInitQueue.length)return[2];T.info("Processing ".concat(this.preInitQueue.length," pre-initialization errors")),e=0,n=this.preInitQueue,o.label=1;case 1:return e<n.length?(t=n[e],[4,this.trackError(t.error,t.componentName,b(b({},t.additionalInfo),{preInitError:!0}))]):[3,4];case 2:o.sent(),o.label=3;case 3:return e++,[3,1];case 4:return this.preInitQueue=[],[2]}}))}))},e.prototype.sendLog=function(e){return y(this,void 0,void 0,(function(){var n,t,o,i,r,l;return w(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),n=O().apiUrl,[4,fetch("".concat(n,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return(t=a.sent()).ok?[3,3]:(i=(o=T).error,r=["Failed to send error log:"],[4,t.text()]);case 2:i.apply(o,r.concat([a.sent()])),a.label=3;case 3:return[3,5];case 4:return l=a.sent(),T.error("Error sending log:",l),[3,5];case 5:return[2]}}))}))},e.prototype.trackError=function(e,n,t){return y(this,void 0,void 0,(function(){var o,i,r;return w(this,(function(l){switch(l.label){case 0:if(this.isInitialized)return[3,5];o={org_id:"UNINITALIZED",event_data:{message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:n,additionalInfo:b(b({},t),{preInitError:!0,timestamp:Date.now()}),timestamp:Date.now()},metadata:dn(),event_type:rn.ERROR,user_id:this.userId},l.label=1;case 1:return l.trys.push([1,3,,4]),[4,this.sendLog(o)];case 2:return l.sent(),[3,4];case 3:return l.sent(),this.preInitQueue.push({error:e,componentName:n,additionalInfo:t}),T.warn("Error tracked before initialization, queuing:",e),[3,4];case 4:return[2];case 5:return i={message:e instanceof Error?e.message:e,stack:e instanceof Error?e.stack:void 0,componentName:n,additionalInfo:b(b({},t),{timestamp:Date.now()}),timestamp:Date.now()},r={org_id:this.apiKey||"UNINITALIZED",event_data:i,metadata:dn(),event_type:rn.ERROR,user_id:this.userId},[4,this.sendLog(r)];case 6:return l.sent(),[2]}}))}))},e.prototype.trackInfo=function(e,n,t){return y(this,void 0,void 0,(function(){var o,i;return w(this,(function(r){switch(r.label){case 0:return this.apiKey?(o={message:e,componentName:n,additionalInfo:t,timestamp:Date.now()},i={org_id:this.apiKey,event_data:o,metadata:dn(),event_type:rn.INFO,user_id:this.userId},[4,this.sendLog(i)]):(T.error("Error tracking not initialized"),[2]);case 1:return r.sent(),[2]}}))}))},e}(),mn=vn.getInstance(),gn="MISSING_API_KEY",_n="INVALID_API_KEY",bn="CONFIG_FETCH_FAILED",yn="SDK_INIT_FAILED",wn="ERROR_TRACKING_INIT_FAILED",En="API_REQUEST_FAILED",In="NETWORK_ERROR",Tn="INVALID_RESPONSE",Sn="IFRAME_LOAD_FAILED",xn="COOKIE_ACCESS_ERROR",An="COMPONENT_RENDER_ERROR",Cn="INITIALIZATION_ERROR",On="API_ERROR",Dn="RUNTIME_ERROR",Rn="COMPONENT_ERROR",Nn=((un={})[gn]=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.")},un[_n]=function(e){return"SDK Initialization Failed: Provided API key '".concat(e,"' is invalid. API key must be a non-empty string in UUID format.")},un[bn]=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):"")},un[En]=function(e,n,t){return"API Request Failed: Server responded with status ".concat(e," for ").concat(t?"endpoint ".concat(t):"request"," - ").concat(n)},un[In]=function(e){return"Network Error: Failed to communicate with server".concat(e.url?" at ".concat(e.url):"").concat(e.error?" - ".concat(e.error):"")},un[Sn]=function(e){return"Failed to load chatbot interface".concat(e.src?" from ".concat(e.src):"").concat(e.error?". Error: ".concat(e.error):"")},un[Tn]=function(e){return"Invalid API Response: Missing required fields in response data: ".concat(e.join(", "))},un[wn]=function(e){return"Error Tracking Service initialization failed".concat(e.apiKey?" for API key ".concat(e.apiKey):"").concat(e.error?". Error: ".concat(e.error):"")},un[yn]=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)):"")},un[xn]=function(e,n){return"Cookie Access Error: Failed to ".concat(e).concat(n?" cookie '".concat(n,"'"):" cookies",". This may affect user session persistence.")},un[An]=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):"")},un),Ln=function(){var e,n=navigator.userAgent;if(null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands){var t=navigator.userAgentData.brands.find((function(e){return"Google Chrome"===e.brand}));if(null==t?void 0:t.version)return t.version}var o=n.match(/(Chrome|Firefox|Safari|Edge|Opera)\/(\d+\.\d+)/);return o?o[2]:"Unknown"},kn=function(){var e,n,t=dn();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===(n=null===navigator||void 0===navigator?void 0:navigator.languages)||void 0===n?void 0:n[0])||"en",browser_version:Ln(),os:null==t?void 0:t.os,referral_url:(null===document||void 0===document?void 0:document.referrer)||"",system_info:t}};!function(e){e.UPDATE_OVERRIDES="updateOverrides",e.I_CAN_AUTHENTICATE="i_can_authenticate",e.I_LOADED_LAUNCHER="i_loaded_launcher",e.I_OPENED_IFRAME="i_opened_iframe",e.I_CLICKED_PROACTIVE_BUBBLE="i_clicked_proactive_bubble",e.CAPTURED_SESSION_DATA="capturedSessionData",e.UPDATE_USER_PROFILE="updateUserProfile",e.OPENED_IFRAME_EVENT="openedIframe"}(pn||(pn={}));var Mn=n((function(n){var o,l,a,s,c=n.config,d=n.isVisible,u=n.onClose,p=n.onEvent,f=n.onIframeLoaded,h=n.onInternalEvent,v=n.position,m=n.bottomSpacing,g=n.overrides,_=t(null),y=t(!1),w=t(!1);t();var E=t(!1),I=v||(null===(o=c.interface_properties)||void 0===o?void 0:o.position)||"Right",T=null!==(a=null!=m?m:null===(l=c.interface_properties)||void 0===l?void 0:l.bottom_spacing)&&void 0!==a?a:20,S=r((function(e,n){var t=_.current;(null==t?void 0:t.contentWindow)&&t.contentWindow.postMessage(e,n)}),[]),C=r((function(){var e,n=_.current;if(n){var t=((e={width:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vw":"26%",minWidth:(null===window||void 0===window?void 0:window.innerWidth)<560?"300px":"400px",height:(null===window||void 0===window?void 0:window.innerWidth)<560?"100vh":"calc(100vh - 2rem - 10vh - ".concat(T,"px)"),borderRadius:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"1rem",position:(null===window||void 0===window?void 0:window.innerWidth)<560?"fixed":"",maxHeight:(null===window||void 0===window?void 0:window.innerWidth)<560?"100%":"50rem",top:(null===window||void 0===window?void 0:window.innerWidth)<560?"0":"calc(10vh - 32px)"})[I.toLowerCase()]=(null===window||void 0===window?void 0:window.innerWidth)<560?"0":void 0,e.flexDirection=(null===window||void 0===window?void 0:window.innerWidth)<560?"column":void 0,e.flexGrow=(null===window||void 0===window?void 0:window.innerWidth)<560?"1":void 0,e);Object.assign(n.style,t)}}),[T,I]);return i((function(){var e=_.current;if(e&&!y.current){var n=O().copilotUrl;Object.assign(e.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(I.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),e.src="".concat(n,"/chatbot-plugin?id=").concat(c.chatbotId),y.current=!0,C();var t=function(){var t,o,i,r,l,a,s,d,u,p,h,v,m,_,y=new URL(e.src).origin||n;if(S({domain:null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.hostname,name:"checkDomain"},y),g){var E={header_avatar:null!==(o=null==g?void 0:g.header_avatar)&&void 0!==o?o:null,agent_avatar:null!==(i=null==g?void 0:g.agent_avatar)&&void 0!==i?i:null,header_title:null!==(r=null==g?void 0:g.header_title)&&void 0!==r?r:null,header_subtitle:null!==(l=null==g?void 0:g.header_subtitle)&&void 0!==l?l:null,header_title_text_color:null!==(a=null==g?void 0:g.header_title_text_color)&&void 0!==a?a:null,header_subtitle_text_color:null!==(s=null==g?void 0:g.header_subtitle_text_color)&&void 0!==s?s:null,header_bg:null!==(d=null==g?void 0:g.header_bg)&&void 0!==d?d:null};S({domain:null===(u=null===window||void 0===window?void 0:window.location)||void 0===u?void 0:u.hostname,action:pn.UPDATE_OVERRIDES,data:E},n)}if(!(null==w?void 0:w.current)&&e.contentWindow){S({domain:null===(p=null===window||void 0===window?void 0:window.location)||void 0===p?void 0:p.hostname,action:pn.I_CAN_AUTHENTICATE,data:{show_history:null==c?void 0:c.show_history}},n);var I=K();S({domain:null===(h=null===window||void 0===window?void 0:window.location)||void 0===h?void 0:h.hostname,action:pn.I_LOADED_LAUNCHER,data:b(b({ws_url:null==c?void 0:c.ws_url,userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:b(b({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:b(b({},(null===(v=null==c?void 0:c.userProfile)||void 0===v?void 0:v.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null==c?void 0:c.isAnonymous},I?{proactiveData:I}:{}),{show_history:null==c?void 0:c.show_history,init_load_image:(null===(_=null===(m=null==c?void 0:c.images)||void 0===m?void 0:m.header_image_url)||void 0===_?void 0:_.url)||(null==c?void 0:c.brand_logo_url),init_load_bot_name:null==c?void 0:c.name})},n),w.current=!0}null==f||f()};return e.addEventListener("load",t),function(){return e.removeEventListener("load",t)}}}),[c.chatbotId,null===(s=c.interface_properties)||void 0===s?void 0:s.position,C,g]),i((function(){var e,n,t,o,i=_.current;if(i&&y.current){var r=(null===(e=c.interface_properties)||void 0===e?void 0:e.position)||"Right";if(d?(Object.assign(i.style,{transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"block"}),i.getBoundingClientRect(),setTimeout((function(){Object.assign(i.style,{transform:"scale(1) translate3d(0,0,0)",opacity:"1",transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"})}),20)):(E.current=!1,i.style.transition="none",i.getBoundingClientRect(),Object.assign(i.style,{opacity:"0",transform:"scale(0.3) translate3d(".concat((r.toLowerCase(),"0"),",40px,0)"),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out"}),setTimeout((function(){!d&&i&&(i.style.display="none")}),200)),i.contentWindow&&d){var l=O().copilotUrl;if(S({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,name:"openFrame"},l),E.current)E.current=!1;else{var a=K();console.log("proactiveData registerUserId===>",a),S({domain:null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.hostname,action:pn.I_OPENED_IFRAME,data:b(b({ws_url:null==c?void 0:c.ws_url,userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:b(b({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:b(b({},(null===(o=null==c?void 0:c.userProfile)||void 0===o?void 0:o.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null==c?void 0:c.isAnonymous},a?{proactiveData:a}:{}),{show_history:null==c?void 0:c.show_history})},l)}}}}),[d,c.userId,c.token,c.userProfile]),i((function(){var e=function(e){var n,t,o,i;if(_.current&&w.current){E.current=!0;var r=(null==e?void 0:e.detail)||{},l=O().copilotUrl;S({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,action:pn.I_CLICKED_PROACTIVE_BUBBLE,data:{userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:b(b({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:b(b({},(null===(t=null==c?void 0:c.userProfile)||void 0===t?void 0:t.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null==c?void 0:c.isAnonymous,ws_url:null==c?void 0:c.ws_url,proactiveData:{input_id:null,message_id:(null==r?void 0:r.message_id)||null,content_string:(null==r?void 0:r.content_string)||null,content_id:(null==r?void 0:r.content_id)||null},show_history:null==c?void 0:c.show_history}},l),console.log("message should have been sent===>",null===(o=_.current)||void 0===o?void 0:o.contentWindow,{userId:null==c?void 0:c.userId,token:null==c?void 0:c.token,userProfile:b(b({},null==c?void 0:c.userProfile),{__INT_SYS_INFO__:b(b({},(null===(i=null==c?void 0:c.userProfile)||void 0===i?void 0:i.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null==c?void 0:c.isAnonymous,ws_url:null==c?void 0:c.ws_url,proactiveData:{input_id:null,message_id:(null==r?void 0:r.message_id)||null,content_string:(null==r?void 0:r.content_string)||null,content_id:(null==r?void 0:r.content_id)||null}})}};return window.addEventListener("rblyn:proactiveClick",e),function(){return window.removeEventListener("rblyn:proactiveClick",e)}}),[null==c?void 0:c.userId,null==c?void 0:c.token,null==c?void 0:c.userProfile,null==c?void 0:c.isAnonymous]),i((function(){if(_.current&&y.current){var e=O().copilotUrl;d&&(null==p||p({type:x.CHATBOT_OPENED,timestamp:Date.now()}),h(x.CHATBOT_OPENED));var n=function(n){var t,o,i,r,l,a,s;if(n.origin===e){if("closeChatbot"===n.data)return void u();if("CHATBOT_TOKEN_EXHAUSTED"===(null===(t=n.data)||void 0===t?void 0:t.type))return void h(A.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null===(o=n.data)||void 0===o?void 0:o.type)&&(null==p||p({type:x.CHATBOT_LOADED,timestamp:Date.now()}),h(x.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null===(i=n.data)||void 0===i?void 0:i.type)&&(null==p||p({type:x.CHAT_INITIALIZED,timestamp:Date.now()}),h(x.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null===(r=n.data)||void 0===r?void 0:r.type)&&(null==p||p({type:x.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),h(x.CHAT_INITIALIZATION_FAILED,{error:null===(l=n.data)||void 0===l?void 0:l.error})),"SESSION_REFRESHED"===(null===(a=n.data)||void 0===a?void 0:a.type)&&(null==p||p({type:x.SESSION_REFRESHED,timestamp:Date.now()}),h(x.SESSION_REFRESHED)),"CHAT_MOVED"===(null===(s=n.data)||void 0===s?void 0:s.type)&&h(A.CHAT_MOVED,{from:n.data.from,to:n.data.to,trigger:n.data.trigger})}};return null===window||void 0===window||window.addEventListener("message",n),function(){return null===window||void 0===window?void 0:window.removeEventListener("message",n)}}}),[u,p,h,c.chatbotId,d]),i((function(){var e=_.current;if(e&&y.current){var n=function(){mn.trackError(new Error(Nn[Sn]({src:e.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:Sn,errorType:Dn,context:{config:c,iframeUrl:e.src,timestamp:Date.now()}})};return e.addEventListener("error",n),function(){return e.removeEventListener("error",n)}}}),[c]),i((function(){if(_.current&&c&&d){_.current;var e=O().copilotUrl;S({action:pn.UPDATE_USER_PROFILE,user_profile:c.userProfile,show_history:null==c?void 0:c.show_history},e),S({action:pn.OPENED_IFRAME_EVENT,user_profile:c.userProfile,show_history:null==c?void 0:c.show_history},e)}}),[c.userProfile,d]),e.createElement("iframe",{allow:"microphone",ref:_,id:"chat-iframe-rbyln",style:{display:"none"}})})),zn=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.state={hasError:!1},n}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 t(){this.constructor=e}d(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}(n,e),n.getDerivedStateFromError=function(e){return{hasError:!0}},n.prototype.componentDidCatch=function(e,n){mn.trackError(new Error(Nn[An]({component:this.props.componentName||void 0,error:e.message,stack:n.componentStack})),this.props.componentName||void 0,{errorCode:An,errorType:Rn,context:{originalError:e,componentStack:n.componentStack,timestamp:Date.now()}})},n.prototype.render=function(){return this.state.hasError?null:this.props.children},n}(l),Pn=function(e,n,t,o){return y(void 0,void 0,void 0,(function(){var i,r,l,a,s,c,d,u;return w(this,(function(p){switch(p.label){case 0:i=O().apiUrl,r="".concat(i,"/chat/chatbot/get/"),T.log("endpointUrl",r),l={client_user_id:n,org_id:e,token:t||void 0,internal_user_id:o||void 0,extra_info:{},launcher_info:kn()},p.label=1;case 1:return p.trys.push([1,6,,7]),[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})];case 2:return(a=p.sent()).ok?[3,4]:[4,a.text()];case 3:throw s=p.sent(),new Error(Nn[En](a.status,s));case 4:return[4,a.json()];case 5:c=p.sent();try{String(l.org_id||"")}catch(e){}if(!(null===(u=null==c?void 0:c.user)||void 0===u?void 0:u.org_info))throw new Error(Nn[Tn](["user","org_info"]));return[2,c];case 6:throw d=p.sent(),mn.trackError(d instanceof Error?d:new Error(Nn[In]({error:String(d)})),"fetchChatbotConfig",{errorCode:d instanceof Error&&d.message.includes("API Request Failed")?En:In,errorType:On,context:{chatbotId:e,userId:n,apiUrl:i,statusCode:d instanceof Response?d.status:void 0,timestamp:Date.now(),requestPayload:{client_user_id:n,org_id:e}}}),d;case 7:return[2]}}))}))},Hn=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var n=16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)}))},Fn=function(e){var n,t="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===t.length)return null===(n=t.pop())||void 0===n?void 0:n.split(";").shift()},Un=function(e,n,t){var o=new Date;o.setTime(o.getTime()+24*t*60*60*1e3),document.cookie="".concat(e,"=").concat(n,";expires=").concat(o.toUTCString(),";path=/")},Bn=function(e){var n=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 n=n.split(";").map((function(e){var n=e.split("="),t=n[0],o=n.slice(1).join("=").trim();return{name:t=t.trim(),value:o?decodeURIComponent(o):""}})),n},Wn=function(){function e(e){this.logoContainer=null,this.iframe=null,this.bubblePromptContainer=null,this.chatBtnImage=null,this.isIframeLoaded=!1,this.config=e,this.validateDomain()&&this.init(),null===window||void 0===window||window.addEventListener("message",this.onCloseListener.bind(this),!1)}return e.prototype.sendMessageToIframe=function(e,n){var t;(null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)&&this.iframe.contentWindow.postMessage(e,n)},e.prototype.onCloseListener=function(e){e.origin===this.config.domain&&"closeChatbot"===e.data&&this.closeIframe()},e.prototype.validateDomain=function(){var e,n=this.config.domain,t=null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.origin;return T.log("expectedDomain, to current domain",n,t,n===t),n===t},e.prototype.createChatBubblContainer=function(){var e,n=this,t=document.createElement("div");t.id="chatbase-message-bubbles",Object.assign(t.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 o=document.createElement("div");o.classList.add("close-btn"),o.textContent="✕",Object.assign(o.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 o=n.createMessageBubble(e);t.appendChild(o)})),t.appendChild(o),document.body.appendChild(t)},e.prototype.createMessageBubble=function(e){var n=document.createElement("div");this.bubblePromptContainer=n,Object.assign(n.style,{display:"flex",position:"relative",justifyContent:"flex-end"});var t=document.createElement("div");t.classList.add("message"),t.textContent=e,Object.assign(t.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 o=document.createElement("button");return o.innerHTML="&times;",Object.assign(o.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"}),o.addEventListener("click",(function(){n.remove()})),n.appendChild(o),n.appendChild(t),n},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:I(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 n,t,o=document.createElement("img");o.src=this.config.launcher_type?(null===(t=null===(n=this.config.images)||void 0===n?void 0:n.launcher_image_url)||void 0===t?void 0:t.url)||"".concat(this.config.domain,"/chatbubble.png"):this.config.image_url||"".concat(this.config.domain,"/chatbubble.png"),o.alt="Chat",Object.assign(o.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover"}),this.chatBtnImage=o,e.innerHTML="",e.appendChild(o)},e.prototype.createIframe=function(){var e=this;T.log("RobylonConfig?.domain====>",this.config.domain);var n=document.createElement("iframe");Object.assign(n.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"}),n.src="".concat(this.config.domain,"/chatbot-plugin?id=").concat(this.config.chatbotId),T.log("iframe.src====>",n.src),document.body.appendChild(n),this.iframe=n;var t=function(){(null===window||void 0===window?void 0:window.innerWidth)<560?Object.assign(n.style,{width:"100vw",minWidth:"300px",right:"0",bottom:"0",height:"100vh",flexDirection:"column",flexGrow:"1",borderRadius:"0",top:"0",maxHeight:"100%"}):Object.assign(n.style,{width:"26%",minWidth:"400px",right:"32px",bottom:"86px",height:"calc(100vh - 3rem - 10vh)",borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"45rem"})};t(),null===window||void 0===window||window.addEventListener("resize",t),n.addEventListener("load",(function(){var t,o,i,r,l;if(e.iframe){var a=new URL(e.iframe.src).origin||e.config.domain;null===(t=n.contentWindow)||void 0===t||t.postMessage({domain:null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.hostname,name:"checkDomain"},a),null===(i=n.contentWindow)||void 0===i||i.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:b(b({},e.config.userProfile||{}),{__INT_SYS_INFO__:b(b({},(null===(l=e.config.userProfile)||void 0===l?void 0:l.__INT_SYS_INFO__)||{}),kn())})}},a),e.isIframeLoaded=!0,e.createFloatingButton()}})),null===window||void 0===window||window.addEventListener("message",(function(t){var o,i;if(t.origin===e.config.domain){if("captureSessionData"===t.data){var r="66b33d16-5b38-4693-8772-1a1bd7dd412d"===e.config.chatbotId,l={cookies:Bn(r),localStorage:JSON.stringify(localStorage),sessionStorage:JSON.stringify(sessionStorage),action:"capturedSessionData",domain_name:null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.hostname};null===(i=n.contentWindow)||void 0===i||i.postMessage(l,e.config.domain||"*")}"expand"===t.data&&(e.adjustIframeWidth(),n.style.height="calc(100vh - 120px)",n.style.bottom="86px"),"collapse"===t.data&&Object.assign(n.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;T.log("screenWidth",e),this.iframe.style.width=e<832?"".concat(e-64,"px"):"800px"}},e.prototype.loadSvgInline=function(e){var n=document.createElement("div");n.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 t=n.querySelector("svg");e.innerHTML="",t&&e.appendChild(t)},e.prototype.toggleIcon=function(e,n){"block"===n.style.display?this.loadSvgInline(e):this.loadImage(e)},e.prototype.toggleIframe=function(){var e;if(T.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;T.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":"cover",this.bubblePromptContainer&&(this.bubblePromptContainer.style.display="none"),T.log("this.bubblePromptContainer",this.bubblePromptContainer)}},e.prototype.closeIframe=function(){this.iframe&&this.logoContainer&&this.chatBtnImage&&(this.iframe.style.display="none",this.toggleIcon(this.logoContainer,this.iframe),this.chatBtnImage.style.objectFit="cover")},e.prototype.init=function(){this.createIframe()},e}(),jn=function(e,n,t){if(e.chatbotId&&e.userId)try{new Wn(e);n(!0),T.log("Robylon SDK initialized successfully.")}catch(e){t(e instanceof Error?e.message:"Failed to initialize SDK")}else t("Incomplete configuration for SDK initialization.")},Vn=function(e,n,t,o){return y(void 0,void 0,void 0,(function(){var i,r,l,a,s,c,d,u;return w(this,(function(p){switch(p.label){case 0:return p.trys.push([0,5,,6]),i=O().apiUrl,r="".concat(i,"/chat/chatbot/get/"),T.log("endpointUrl",r),l={client_user_id:n||null,org_id:e,token:t||void 0,internal_user_id:o||void 0,extra_info:{},launcher_info:kn()},[4,fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})];case 1:return(a=p.sent()).ok?[3,3]:[4,a.text()];case 2:throw s=p.sent(),new Error(Nn[En](a.status,s));case 3:return[4,a.json()];case 4:if(c=p.sent(),!(null===(u=null==c?void 0:c.user)||void 0===u?void 0:u.org_info))throw new Error(Nn[Tn](["user","org_info"]));return[2,c];case 5:throw d=p.sent(),mn.trackError(d instanceof Error?d:new Error(Nn[In]({error:String(d)})),"fetchChatbotConfig",{errorCode:d instanceof Error&&d.message.includes("API Request Failed")?En:In,errorType:On,context:{apiKey:e,userId:n,timestamp:Date.now()}}),d;case 6:return[2]}}))}))},Gn=function(e){return y(void 0,void 0,void 0,(function(){var n,t,o,i,r,l,a,s,c,d,h,v,m,g,_,y,E,I,S,x,A,C,O,D,R,N,L,k,M,z,P,H,F,U,B,W,j,V,G,Y,K,X,q,J,Z,Q,$,ee,ne;return w(this,(function(w){switch(w.label){case 0:return n=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),t=n.user_id||void 0,o=!1,t?i=Fn("rblyn_anon")||Hn():(t=Fn("rblyn_anon")||Hn(),Un("rblyn_anon",t,365),o=!0,i=t),[4,Vn(n.api_key,t,n.user_token,i)];case 1:r=w.sent();try{n.api_key}catch(e){T.warn("Failed to inject mock proactive messages",e)}return l=dn(),a=kn(),te=n.user_profile,s=te?Object.fromEntries(Object.entries(te).map((function(e){var n=e[0],t=e[1];return"boolean"==typeof t||"number"==typeof t?[n,t]:[n,String(t)]}))):{},c=b(b(b({},l),{__INT_SYS_INFO__:b(b({},l),a)}),s),[2,{chatbotId:n.api_key,name:(null===(d=r.user.org_info.brand_config)||void 0===d?void 0:d.display_name)||"",userId:t,token:n.user_token,isAnonymous:o,domain:"",show_launcher:null===(v=null===(h=r.user.org_info)||void 0===h?void 0:h.show_launcher)||void 0===v||v,auto_launch:null!==(g=null===(m=r.user.org_info)||void 0===m?void 0:m.auto_launch)&&void 0!==g&&g,brand_colour:(null===(y=null===(_=r.user.org_info.brand_config)||void 0===_?void 0:_.colors)||void 0===y?void 0:y.brand_color)||"",image_url:(null===(I=null===(E=r.user.org_info)||void 0===E?void 0:E.brand_config)||void 0===I?void 0:I.launcher_logo_url)||"",brand_logo_url:(null===(x=null===(S=r.user.org_info)||void 0===S?void 0:S.brand_config)||void 0===x?void 0:x.launcher_logo_url)||"",userProfile:c,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(A=r.user.org_info.brand_config)||void 0===A?void 0:A.display_name)||"",welcome_message:(null===(C=r.user.org_info.brand_config)||void 0===C?void 0:C.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(O=r.user.org_info.brand_config)||void 0===O?void 0:O.redirect_url)||""},launcher_type:(null===(D=r.user.org_info.brand_config)||void 0===D?void 0:D.launcher_type)||f.IMAGE,launcher_properties:{text:(null===(N=null===(R=r.user.org_info.brand_config)||void 0===R?void 0:R.launcher_properties)||void 0===N?void 0:N.text)||""},images:{launcher_image_url:{url:(null===(M=null===(k=null===(L=r.user.org_info.brand_config)||void 0===L?void 0:L.images)||void 0===k?void 0:k.launcher_image_url)||void 0===M?void 0:M.url)||""},header_image_url:{url:(null===(H=null===(P=null===(z=r.user.org_info.brand_config)||void 0===z?void 0:z.images)||void 0===P?void 0:P.header_image_url)||void 0===H?void 0:H.url)||""}},proactive_message_obj:Yn(null===(B=null===(U=null===(F=null==r?void 0:r.user)||void 0===F?void 0:F.org_info)||void 0===U?void 0:U.brand_config)||void 0===B?void 0:B.proactive_message_obj),interface_properties:{position:(null===(j=null===(W=r.user.org_info.brand_config)||void 0===W?void 0:W.interface_properties)||void 0===j?void 0:j.position)||p.RIGHT,side_spacing:(null===(G=null===(V=r.user.org_info.brand_config)||void 0===V?void 0:V.interface_properties)||void 0===G?void 0:G.side_spacing)||20,bottom_spacing:(null===(K=null===(Y=r.user.org_info.brand_config)||void 0===Y?void 0:Y.interface_properties)||void 0===K?void 0:K.bottom_spacing)||20},interface_type:(null===(X=r.user.org_info.brand_config)||void 0===X?void 0:X.interface_type)||u.WIDGET,launcher_delay:(null===(q=r.user.org_info.brand_config)||void 0===q?void 0:q.launcher_delay)||{enabled:!1,delay:0},launcher_scroll:function(){var e,n,t,o,i,l,a;console.log("[Config] Raw API response launcher_scroll",{raw:null===(e=r.user.org_info.brand_config)||void 0===e?void 0:e.launcher_scroll,type:typeof(null===(n=r.user.org_info.brand_config)||void 0===n?void 0:n.launcher_scroll),enabled:null===(o=null===(t=r.user.org_info.brand_config)||void 0===t?void 0:t.launcher_scroll)||void 0===o?void 0:o.enabled,depth:null===(l=null===(i=r.user.org_info.brand_config)||void 0===i?void 0:i.launcher_scroll)||void 0===l?void 0:l.depth});var s=(null===(a=r.user.org_info.brand_config)||void 0===a?void 0:a.launcher_scroll)||{enabled:!1,depth:0};return console.log("[Config] Parsed launcher_scroll",s),s}(),auto_launch_delay:(null===(J=r.user.org_info.brand_config)||void 0===J?void 0:J.auto_launch_delay)||{enabled:!1,seconds:0},auto_launch_scroll:(null===(Z=r.user.org_info.brand_config)||void 0===Z?void 0:Z.auto_launch_scroll)||{enabled:!1,depth:0},launcher_size_multiplier:null!==($=null===(Q=r.user.org_info.brand_config)||void 0===Q?void 0:Q.launcher_size_multiplier)&&void 0!==$?$:1,ws_url:null===(ne=null===(ee=r.user)||void 0===ee?void 0:ee.router_connection_info)||void 0===ne?void 0:ne.url}]}var te}))}))},Yn=function(e){if(e){var n=(Array.isArray(e)?e:[e]).filter(Boolean).map((function(e){var n,t,o,i={message_id:String(null!==(n=null==e?void 0:e.message_id)&&void 0!==n?n:""),org_id:String(null!==(t=null==e?void 0:e.org_id)&&void 0!==t?t:""),name:null==e?void 0:e.name,content:null==e?void 0:e.content,send_time_type:null==e?void 0:e.send_time_type,created_by_name:null==e?void 0:e.created_by_name,updated_by_name:null==e?void 0:e.updated_by_name,updated_at:null==e?void 0:e.updated_at,created_at:null==e?void 0:e.created_at,delay:"number"==typeof(null==e?void 0:e.delay)?e.delay:void 0,delay_type:"scroll"===(null==e?void 0:e.delay_type)||"time"===(null==e?void 0:e.delay_type)?e.delay_type:void 0,scroll_threshold:(o=Number(null==e?void 0:e.scroll_threshold),Number.isFinite(o)?o:void 0),content_multiple:Array.isArray(null==e?void 0:e.content_multiple)?e.content_multiple:(null==e?void 0:e.content)?[{message:String(e.content),message_display_attributes:[]}]:[]};return(null==e?void 0:e.content)&&!(null==e?void 0:e.content_multiple)&&T.warn("[Robylon SDK] proactive_message.content is deprecated; use content_multiple[].message instead."),i}));return n.length?n:void 0}},Kn=function(e){var n=a((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||{}}}(e)}),[e.api_key,e.user_id,e.user_token,JSON.stringify(e.user_profile)]),t=o({isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1}),l=t[0],s=t[1],c=a((function(){return n.user_profile?Object.fromEntries(Object.entries(n.user_profile).map((function(e){var n=e[0],t=e[1];return"boolean"==typeof t||"number"==typeof t?[n,t]:[n,String(t)]}))):{}}),[JSON.stringify(n.user_profile)]),d=r((function(e){s((function(n){return b(b({},n),e)}))}),[]),h=r((function(){return y(void 0,void 0,void 0,(function(){var e,t,o,i,r,l,a,s,h,v,m,g,_,y,E,I,T,S,x,A,C,O,D,R,N,L,k,M,z,P,H,F,U,B,W,j,V,G,Y,K,X,q,J,Z,Q,$,ee,ne,te,oe,ie,re,le,ae,se,ce,de,ue,pe,fe,he;return w(this,(function(w){switch(w.label){case 0:if(!n.api_key)return mn.trackError(new Error(Nn[gn](n.api_key)),"useChatbotState",{errorCode:gn,errorType:Cn,context:{timestamp:Date.now()}}),[2];d({isInitializing:!0}),w.label=1;case 1:return w.trys.push([1,4,5,6]),e=n.user_id||void 0,t=!1,o=void 0,e?o=Fn("rblyn_anon")||Hn():(e=Fn("rblyn_anon")||Hn(),o=e,Un("rblyn_anon",e,365),t=!0),[4,Pn(n.api_key,e,n.user_token,o)];case 2:return i=w.sent(),r=dn(),l=kn(),a=b(b(b(b({},r),{__INT_SYS_INFO__:b(b({},r),l)}),c),{internal_user_id:o}),s={chatbotId:n.api_key,name:(null===(m=i.user.org_info.brand_config)||void 0===m?void 0:m.name)||"",userId:e,token:n.user_token,isAnonymous:t,domain:"",show_launcher:null===(_=null===(g=i.user.org_info)||void 0===g?void 0:g.show_launcher)||void 0===_||_,auto_launch:null!==(E=null===(y=i.user.org_info)||void 0===y?void 0:y.auto_launch)&&void 0!==E&&E,show_history:null===(S=null===(T=null===(I=null==i?void 0:i.user)||void 0===I?void 0:I.org_info)||void 0===T?void 0:T.brand_config)||void 0===S?void 0:S.enable_history,brand_colour:(null===(A=null===(x=i.user.org_info.brand_config)||void 0===x?void 0:x.colors)||void 0===A?void 0:A.brand_color)||"",image_url:(null===(O=null===(C=i.user.org_info)||void 0===C?void 0:C.brand_config)||void 0===O?void 0:O.launcher_logo_url)||"",brand_logo_url:(null===(R=null===(D=i.user.org_info)||void 0===D?void 0:D.brand_config)||void 0===R?void 0:R.launcher_logo_url)||"",userProfile:a,chat_interface_config:{chat_bubble_prompts:[],display_name:(null===(N=i.user.org_info.brand_config)||void 0===N?void 0:N.display_name)||"",welcome_message:(null===(L=i.user.org_info.brand_config)||void 0===L?void 0:L.welcome_message)||"Hey! What can we help you with today?",redirect_url:(null===(k=i.user.org_info.brand_config)||void 0===k?void 0:k.redirect_url)||""},interface_properties:{position:(null===(z=null===(M=i.user.org_info.brand_config)||void 0===M?void 0:M.interface_properties)||void 0===z?void 0:z.position)||p.RIGHT,side_spacing:null!==(F=null===(H=null===(P=i.user.org_info.brand_config)||void 0===P?void 0:P.interface_properties)||void 0===H?void 0:H.side_spacing)&&void 0!==F?F:20,bottom_spacing:null!==(W=null===(B=null===(U=i.user.org_info.brand_config)||void 0===U?void 0:U.interface_properties)||void 0===B?void 0:B.bottom_spacing)&&void 0!==W?W:20},interface_type:(null===(j=i.user.org_info.brand_config)||void 0===j?void 0:j.interface_type)||u.WIDGET,launcher_type:(null===(V=i.user.org_info.brand_config)||void 0===V?void 0:V.launcher_type)||f.IMAGE,launcher_properties:{text:(null===(Y=null===(G=i.user.org_info.brand_config)||void 0===G?void 0:G.launcher_properties)||void 0===Y?void 0:Y.text)||""},images:{launcher_image_url:{url:(null===(q=null===(X=null===(K=i.user.org_info.brand_config)||void 0===K?void 0:K.images)||void 0===X?void 0:X.launcher_image_url)||void 0===q?void 0:q.url)||""},header_image_url:{url:(null===(Q=null===(Z=null===(J=i.user.org_info.brand_config)||void 0===J?void 0:J.images)||void 0===Z?void 0:Z.header_image_url)||void 0===Q?void 0:Q.url)||""}},proactive_message_obj:Yn(null===(ne=null===(ee=null===($=null==i?void 0:i.user)||void 0===$?void 0:$.org_info)||void 0===ee?void 0:ee.brand_config)||void 0===ne?void 0:ne.proactive_message_obj),launcher_delay:(null===(oe=null===(te=i.user.org_info)||void 0===te?void 0:te.brand_config)||void 0===oe?void 0:oe.launcher_delay)||{enabled:!1,delay:0},launcher_scroll:(null===(re=null===(ie=i.user.org_info)||void 0===ie?void 0:ie.brand_config)||void 0===re?void 0:re.launcher_scroll)||{enabled:!1,depth:0},auto_launch_delay:(null===(ae=null===(le=i.user.org_info)||void 0===le?void 0:le.brand_config)||void 0===ae?void 0:ae.auto_launch_delay)||{enabled:!1,seconds:0},auto_launch_scroll:(null===(ce=null===(se=i.user.org_info)||void 0===se?void 0:se.brand_config)||void 0===ce?void 0:ce.auto_launch_scroll)||{enabled:!1,depth:0},launcher_size_multiplier:null!==(pe=null===(ue=null===(de=i.user.org_info)||void 0===de?void 0:de.brand_config)||void 0===ue?void 0:ue.launcher_size_multiplier)&&void 0!==pe?pe:1,ws_url:null===(he=null===(fe=i.user)||void 0===fe?void 0:fe.router_connection_info)||void 0===he?void 0:he.url},[4,new Promise((function(e,n){jn(s,(function(){d({isInitialized:!0,chatbotConfig:s}),e()}),(function(e){n(e)}))}))];case 3:return w.sent(),[3,6];case 4:return h=w.sent(),v=h instanceof Error?h.message:"Failed to initialize chatbot",d({error:v}),mn.trackError(h instanceof Error?h:new Error(v),"useChatbotState",{errorCode:yn,errorType:Cn,context:{timestamp:Date.now()}}),[3,6];case 5:return d({isInitializing:!1}),[7];case 6:return[2]}}))}))}),[n.api_key,n.user_id,n.user_token]);i((function(){n.api_key&&h()}),[h]),i((function(){l.chatbotConfig&&s((function(e){return b(b({},e),{chatbotConfig:b(b({},e.chatbotConfig),{userProfile:b(b({},dn()),c)})})}))}),[c]);var v=r((function(){s((function(e){return b(b({},e),{isIframeVisible:!e.isIframeVisible})}))}),[]),m=r((function(){d({isIframeVisible:!1})}),[]);return b(b({},l),{toggleIframeVisibility:v,closeIframe:m})},Xn=function(n){var t,r,l,a,s,c,d,u=n.children,p=n.config,f=n.position,h=n.sideSpacing,v=n.bottomSpacing,m=o(!1),g=m[0],_=m[1];i((function(){var e=function(){var e=(null===window||void 0===window?void 0:window.innerWidth)<560;_(e)};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]);var y=f||(null===(l=p.interface_properties)||void 0===l?void 0:l.position)||"Right",w=null!==(s=null!=h?h:null===(a=p.interface_properties)||void 0===a?void 0:a.side_spacing)&&void 0!==s?s:20,E=null!==(d=null!=v?v:null===(c=p.interface_properties)||void 0===c?void 0:c.bottom_spacing)&&void 0!==d?d:20;T.log("config",p,y,w);var I={position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column"},S=b(b({},I),((t={bottom:"".concat(E,"px")})[y.toLowerCase()]="".concat(null!=w?w:20,"px"),t.alignItems="Right"===y?"flex-end":"flex-start",t.top=void 0,t["Right"===y?"left":"right"]=void 0,t)),x=b(b({},I),((r={top:0})[y.toLowerCase()]="".concat(null!=w?w:20,"px"),r.alignItems="center",r.bottom=void 0,r["Right"===y?"left":"right"]=void 0,r)),A=g?x:S;return i((function(){console.log("Container screen width changed, isMobile:",g,"Style:",A)}),[g,A]),e.createElement("div",{className:"robylon-chatbot-container",style:A},u)},qn=function(e,n,t,o){var i;if(!document.getElementById(e)){var r=document.createElement("link");r.id=e,r.rel=n,r.href=t,o&&(r.crossOrigin=""),null===(i=document.head)||void 0===i||i.appendChild(r)}},Jn=function(){if(C()){var e="".concat("https://d1h2odiipi7033.cloudfront.net","/");qn("robylon-launcher-cdn-preconnect","preconnect",e,!0),qn("robylon-launcher-cdn-dns-prefetch","dns-prefetch",e,!1)}},Zn=s((function(n,t){var l,s,d,u,p,f,h,v,m,g,_,I,S,A=n.api_key,C=n.user_id,D=n.user_token,R=n.user_profile,N=n.onEvent,L=n.position,k=n.sideSpacing,M=n.bottomSpacing,z=n.show_launcher,P=n.launcher_type,H=n.launcher_properties_text,F=n.overrides,U=n.launcher_size;i((function(){Jn()}),[]);var B="string"==typeof k?""===k||isNaN(Number(k))?void 0:Number(k):k,W="string"==typeof M?""===M||isNaN(Number(M))?void 0:Number(M):M,j="string"==typeof L?"left"===L.toLowerCase()?"Left":"right"===L.toLowerCase()?"Right":void 0:L;i((function(){}));var V=a((function(){return{api_key:A,user_id:C,user_token:D,user_profile:R}}),[A,C,D,R]),G=r((function(e){null==N||N(e)}),[N]),Y=Kn(V),K=Y.isInitialized,X=Y.error,q=Y.chatbotConfig,J=Y.isIframeVisible,Z=Y.toggleIframeVisibility,Q=Y.closeIframe,$=a((function(){return{api_key:A,user_profile:V.user_profile,onEvent:G,chatbotConfig:q?{isAnonymous:q.isAnonymous,userId:q.userId}:null}}),[A,V.user_profile,G,null==q?void 0:q.isAnonymous,null==q?void 0:q.userId]),ee=function(e){var n=e.api_key,t=e.chatbotConfig,o=e.user_profile,i=e.onEvent,l=a((function(){return{isAnonymous:(null==t?void 0:t.isAnonymous)||!1,userId:(null==t?void 0:t.userId)||""}}),[null==t?void 0:t.isAnonymous,null==t?void 0:t.userId]),s=a((function(){return o||{}}),[JSON.stringify(o)]),c=r((function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return y(void 0,E([e],t,!0),void 0,(function(e,t){var o,i,r,a,c,d,u;return void 0===t&&(t={}),w(this,(function(p){switch(p.label){case 0:if(!n)return[2];p.label=1;case 1:return p.trys.push([1,3,,4]),o=O().apiUrl,i=dn(),r=b({trigger_time:Date.now(),channel:"CHATBOT",launch_url:(null===(u=null===window||void 0===window?void 0:window.location)||void 0===u?void 0:u.href)||"",org_id:n,client_user_id:l.isAnonymous?"Anonymous":String(l.userId),event_type:e,user_profile:s},t),a={org_id:n,event_data:r,metadata:b({timestamp:Date.now()},i),event_type:"INFO",user_id:l.userId},[4,fetch("".concat(o,"/users/sdk/record-logs/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})];case 2:if(!(c=p.sent()).ok)throw new Error("Failed to send internal event: ".concat(c.statusText));return[3,4];case 3:return d=p.sent(),T.error("Failed to send internal event:",d),[3,4];case 4:return[2]}}))}))}),[n,l]);return{emitEvent:r((function(e,n){var t=Date.now();e!==x.CHATBOT_BUTTON_CLICKED&&e!==x.CHATBOT_CLOSED&&e!==x.CHATBOT_OPENED&&e!==x.CHATBOT_READY||(i&&i({type:e,timestamp:t,data:n}),c(e,{timestamp:t}))}),[i,c]),onInternalEvent:c}}(b({},$)),ne=ee.emitEvent,te=ee.onInternalEvent;c(t,(function(){return{show:function(){K&&q?J||(Z(),ne(x.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot show - chatbot not ready yet")},hide:function(){K&&q?J&&(Q(),ne(x.CHATBOT_CLOSED)):console.warn("Robylon Chatbot: Cannot hide - chatbot not ready yet")},toggle:function(){K&&q?(Z(),ne(J?x.CHATBOT_CLOSED:x.CHATBOT_BUTTON_CLICKED)):console.warn("Robylon Chatbot: Cannot toggle - chatbot not ready yet")},isReady:K&&!!q}}),[K,q,J,Z,Q,ne]),i((function(){K&&q&&ne(x.CHATBOT_READY)}),[K,q,ne]);var oe=o(!1),ie=oe[0],re=oe[1],le=o(!1),ae=le[0],se=le[1],ce=o(!1),de=ce[0],ue=ce[1],pe=o(!1),fe=pe[0],he=pe[1],ve=o(!1),me=ve[0],ge=ve[1];i((function(){var e,n,t,o,i,r,l,a,s;if(console.log("[RobylonChatbot] Scroll tracking effect running",{chatbotConfig:!!q,launcher_scroll:null==q?void 0:q.launcher_scroll,scrollEnabled:null===(e=null==q?void 0:q.launcher_scroll)||void 0===e?void 0:e.enabled,scrollDepth:null===(n=null==q?void 0:q.launcher_scroll)||void 0===n?void 0:n.depth,scrollEnabledType:typeof(null===(t=null==q?void 0:q.launcher_scroll)||void 0===t?void 0:t.enabled),scrollDepthType:typeof(null===(o=null==q?void 0:q.launcher_scroll)||void 0===o?void 0:o.depth)}),!q)return console.log("[RobylonChatbot] No config, resetting scroll state"),void ue(!1);var c=!0===(null===(i=null==q?void 0:q.launcher_scroll)||void 0===i?void 0:i.enabled),d=null!==(l=null===(r=null==q?void 0:q.launcher_scroll)||void 0===r?void 0:r.depth)&&void 0!==l?l:0;if(console.log("[RobylonChatbot] Scroll config check",{rawLauncherScroll:null==q?void 0:q.launcher_scroll,scrollEnabledRaw:null===(a=null==q?void 0:q.launcher_scroll)||void 0===a?void 0:a.enabled,scrollEnabled:c,scrollDepthRaw:null===(s=null==q?void 0:q.launcher_scroll)||void 0===s?void 0:s.depth,scrollDepth:d,scrollDepthNumber:Number(d),willSetup:c&&Number(d)>0}),!c||Number(d)<=0)return console.log("[RobylonChatbot] Scroll disabled or depth <= 0, resetting state"),void ue(!1);var u=function(){var e=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;console.log("[RobylonChatbot] Checking scroll depth",{currentScrollY:e,requiredDepth:Number(d),hasScrolledPast:e>=Number(d),currentState:de}),e>=Number(d)&&(console.log("[RobylonChatbot] Scroll depth reached! Setting flag to true"),ue(!0))};return console.log("[RobylonChatbot] Checking initial scroll position"),u(),console.log("[RobylonChatbot] Adding scroll event listener"),window.addEventListener("scroll",u,{passive:!0}),function(){console.log("[RobylonChatbot] Removing scroll event listener"),window.removeEventListener("scroll",u)}}),[q,null===(l=null==q?void 0:q.launcher_scroll)||void 0===l?void 0:l.enabled,null===(s=null==q?void 0:q.launcher_scroll)||void 0===s?void 0:s.depth]),i((function(){var e,n,t,o,i,r,l,a,s,c;if(console.log("[RobylonChatbot] Launcher visibility effect running",{hasConfig:!!q,show_launcher:z,configShowLauncher:null==q?void 0:q.show_launcher,hasScrolledPastDepth:de}),!q)return console.log("[RobylonChatbot] No config, hiding launcher"),void re(!1);var d=void 0!==z?Boolean(z):null===(e=null==q?void 0:q.show_launcher)||void 0===e||e;if(console.log("[RobylonChatbot] Final show_launcher decision",{finalShowLauncher:d,propShowLauncher:z,configShowLauncher:null==q?void 0:q.show_launcher}),!d)return console.log("[RobylonChatbot] show_launcher is false, hiding launcher"),re(!1),function(){c&&clearTimeout(c)};var u=!0===(null===(n=null==q?void 0:q.launcher_delay)||void 0===n?void 0:n.enabled),p=null!==(r=null!==(o=null===(t=null==q?void 0:q.launcher_delay)||void 0===t?void 0:t.seconds)&&void 0!==o?o:null===(i=null==q?void 0:q.launcher_delay)||void 0===i?void 0:i.delay)&&void 0!==r?r:0,f=!0===(null===(l=null==q?void 0:q.launcher_scroll)||void 0===l?void 0:l.enabled),h=null!==(s=null===(a=null==q?void 0:q.launcher_scroll)||void 0===a?void 0:a.depth)&&void 0!==s?s:0,v=f&&Number(h)>0;console.log("[RobylonChatbot] Scroll and delay config",{delayEnabled:u,seconds:p,scrollEnabled:f,scrollDepth:h,requiresScroll:v});var m=!0;if(v){var g=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;m=g>=Number(h)||de,console.log("[RobylonChatbot] Scroll condition check",{currentScrollY:g,requiredDepth:Number(h),hasScrolledPastDepthState:de,scrollConditionMet:m})}return v&&!m?(console.log("[RobylonChatbot] Scroll required but condition not met, hiding launcher"),re(!1),function(){c&&clearTimeout(c)}):(u&&Number(p)>0?(console.log("[RobylonChatbot] Delay enabled, setting timeout",{seconds:p}),re(!1),c=window.setTimeout((function(){console.log("[RobylonChatbot] Delay timeout fired, checking scroll condition");var e=!0;if(v){var n=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;e=n>=Number(h)||de,console.log("[RobylonChatbot] Final scroll check in delay timeout",{currentScrollY:n,requiredDepth:Number(h),hasScrolledPastDepthState:de,finalScrollConditionMet:e})}!v||e?(console.log("[RobylonChatbot] Showing launcher after delay"),re(!0)):console.log("[RobylonChatbot] Not showing launcher - scroll condition not met")}),1e3*Number(p))):(console.log("[RobylonChatbot] No delay, showing launcher immediately"),re(!0)),function(){c&&clearTimeout(c)})}),[q,z,null==q?void 0:q.show_launcher,null===(d=null==q?void 0:q.launcher_delay)||void 0===d?void 0:d.enabled,null===(u=null==q?void 0:q.launcher_delay)||void 0===u?void 0:u.seconds,null===(p=null==q?void 0:q.launcher_delay)||void 0===p?void 0:p.delay,null===(f=null==q?void 0:q.launcher_scroll)||void 0===f?void 0:f.enabled,null===(h=null==q?void 0:q.launcher_scroll)||void 0===h?void 0:h.depth,de]),i((function(){var e,n,t;if(q&&!fe){var o=!0===(null===(e=null==q?void 0:q.auto_launch_scroll)||void 0===e?void 0:e.enabled),i=null!==(t=null===(n=null==q?void 0:q.auto_launch_scroll)||void 0===n?void 0:n.depth)&&void 0!==t?t:0;if(o&&!(Number(i)<=0)){var r=function(){me||(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(i)&&ge(!0)};return r(),window.addEventListener("scroll",r,{passive:!0}),function(){window.removeEventListener("scroll",r)}}ge(!1)}}),[q,null===(v=null==q?void 0:q.auto_launch_scroll)||void 0===v?void 0:v.enabled,null===(m=null==q?void 0:q.auto_launch_scroll)||void 0===m?void 0:m.depth,fe,me]),i((function(){var e,n,t,o,i,r,l;if(q&&!fe&&ae){var a=void 0!==z?Boolean(z):null===(e=null==q?void 0:q.show_launcher)||void 0===e||e,s=!0===(null==q?void 0:q.auto_launch);if(a&&s&&ie){var c=!0===(null===(n=null==q?void 0:q.auto_launch_delay)||void 0===n?void 0:n.enabled),d=null!==(o=null===(t=null==q?void 0:q.auto_launch_delay)||void 0===t?void 0:t.seconds)&&void 0!==o?o:0,u=!0===(null===(i=null==q?void 0:q.auto_launch_scroll)||void 0===i?void 0:i.enabled),p=null!==(l=null===(r=null==q?void 0:q.auto_launch_scroll)||void 0===r?void 0:r.depth)&&void 0!==l?l:0,f=u&&Number(p)>0,h=!0;if(f)h=(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(p)||me;if(!f||h){var v=function(){fe||J||(he(!0),Z(),ne(x.CHATBOT_BUTTON_CLICKED))};if(c&&Number(d)>0){var m=window.setTimeout((function(){var e=!0;f&&(e=(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(p)||me);f&&!e||v()}),1e3*Number(d));return function(){clearTimeout(m)}}v()}}}}),[q,z,null==q?void 0:q.show_launcher,null==q?void 0:q.auto_launch,null===(g=null==q?void 0:q.auto_launch_delay)||void 0===g?void 0:g.enabled,null===(_=null==q?void 0:q.auto_launch_delay)||void 0===_?void 0:_.seconds,null===(I=null==q?void 0:q.auto_launch_scroll)||void 0===I?void 0:I.enabled,null===(S=null==q?void 0:q.auto_launch_scroll)||void 0===S?void 0:S.depth,ie,ae,fe,me,J,Z,ne]),i((function(){if(A)try{mn.initialize(A,C)}catch(e){mn.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:wn,errorType:Cn,context:{timestamp:Date.now()}})}else mn.trackError(new Error(Nn[gn](A)),"RobylonChatbot",{errorCode:gn,errorType:Cn,context:{timestamp:Date.now()}})}),[A,C]);var _e=r((function(){Q(),ne(x.CHATBOT_CLOSED)}),[Q,ne]),be=r((function(){Z(),ne(J?x.CHATBOT_CLOSED:x.CHATBOT_BUTTON_CLICKED)}),[Z,ne,J]),ye=a((function(){var e,n,t,o,i;return{config:q,toggleIframe:be,isIframeVisible:J,onEvent:G,onInternalEvent:te,position:j,sideSpacing:B,bottomSpacing:W,launcher_type:P,launcher_properties_text:H,shouldFadeIn:!0===(null===(e=null==q?void 0:q.launcher_delay)||void 0===e?void 0:e.enabled)&&(null!==(i=null!==(t=null===(n=null==q?void 0:q.launcher_delay)||void 0===n?void 0:n.seconds)&&void 0!==t?t:null===(o=null==q?void 0:q.launcher_delay)||void 0===o?void 0:o.delay)&&void 0!==i?i:0)>0||!1,launcher_size:U}}),[q,be,J,G,te,j,B,W,P,H,U]);T.log("floatingButtonProps",ye);var we=a((function(){return{config:q,isVisible:J,onClose:_e,onEvent:G,onIframeLoaded:function(){return se(!0)},onInternalEvent:te,position:j,bottomSpacing:W,overrides:F}}),[q,J,_e,G,te,j,W,F]);return A&&!X&&q?e.createElement(zn,{componentName:"RobylonChatbot"},K?e.createElement(Xn,{config:q,position:j,sideSpacing:B,bottomSpacing:W},e.createElement(zn,{componentName:"ChatbotIframe"},e.createElement(Mn,b({},we))),e.createElement(zn,{componentName:"ChatbotFloatingButton"},(console.log("[RobylonChatbot] Render check",{isLauncherVisible:ie,isIframeLoaded:ae,willRender:ie&&ae}),ie&&ae?e.createElement(ln,b({},ye)):null))):null):null})),Qn=n(Zn,(function(e,n){return e.api_key===n.api_key&&e.user_id===n.user_id&&e.user_token===n.user_token&&JSON.stringify(e.user_profile)===JSON.stringify(n.user_profile)&&e.position===n.position&&e.sideSpacing===n.sideSpacing&&e.bottomSpacing===n.bottomSpacing&&e.show_launcher===n.show_launcher&&e.launcher_type===n.launcher_type&&e.launcher_properties_text===n.launcher_properties_text&&JSON.stringify(e.overrides)===JSON.stringify(n.overrides)&&e.launcher_size===n.launcher_size&&!0})),$n=function(e){var n=o({isLoading:!0,isInitialized:!1,error:null}),t=n[0],r=n[1],l=function(e){r((function(n){return b(b({},n),{isInitialized:e})}))},a=function(e){r((function(n){return b(b({},n),{error:e})}))};return i((function(){!function(){try{jn(e,l,a)}catch(e){r((function(n){return b(b({},n),{error:e instanceof Error?e.message:"Failed to initialize SDK",isLoading:!1})}))}}()}),[e.chatbotId,e.userId]),t},et="data-robylon-launcher-image-root",nt="data-robylon-launcher-chevron-overlay",tt=function(){function e(e){var n=this;this.resizeObserver=null,this.proactiveElement=null,this.urlUnsubscribe=null,this.delayTimers=[],this.scrollHandlers=new Map,this.shownScrollMessages=new Set,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(){n.buttonElement.style.opacity="1"}))}catch(e){}this.setupResizeListener(),this.renderProactiveIfNeeded(),this.urlUnsubscribe=F((function(){n.clearProactiveDelays(),n.renderProactiveIfNeeded(!0)}))}return e.prototype.render=function(){var e,n,t=this,o=O().copilotUrl,i=this.config,r=i.config,l=i.isIframeVisible,a=null!==(e=null==r?void 0:r.launcher_size_multiplier)&&void 0!==e?e:1,s=null!==(n=this.config.launcher_size)&&void 0!==n?n:48*a,c={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:l?"scale(0.85)":"scale(1)",fontFamily:R};if(r.launcher_type===f.IMAGE&&Object.assign(c,{width:"".concat(s,"px"),height:"".concat(s,"px"),borderRadius:"50%",backgroundColor:r.brand_colour}),this.applyResponsiveStyles(c),this.buttonElement.className="message-bubble-container",this.tryUpdateImageLauncherInPlace(s,o))return this.buttonElement.onclick=function(){t.config.toggleIframe(),t.hideProactiveMessages()},void this.renderProactiveIfNeeded();this.buttonElement.innerHTML="",this.buttonElement.appendChild(this.createLauncherElement()),this.buttonElement.onclick=function(){t.config.toggleIframe(),t.hideProactiveMessages()},this.renderProactiveIfNeeded()},e.prototype.getImageLauncherSrc=function(e){var n,t,o=this.config.config;return o.launcher_type?(null===(t=null===(n=o.images)||void 0===n?void 0:n.launcher_image_url)||void 0===t?void 0:t.url)||"".concat(e,"/chatbubble.png"):o.image_url||"".concat(e,"/chatbubble.png")},e.prototype.appendChevronSvg=function(e,n){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width",String(n)),t.setAttribute("height",String(n)),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.style.display="block";var o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d","M19 9L12 16L5 9"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","1.5"),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),t.appendChild(o),e.appendChild(t)},e.prototype.tryUpdateImageLauncherInPlace=function(e,n){var t=this.config,o=t.config,i=t.isIframeVisible;if(!(o.launcher_type===f.IMAGE||void 0===o.launcher_type))return!1;var r=this.buttonElement.querySelector("[".concat(et,"]"));if(!r)return!1;var l=r.querySelector("img");if(!l)return!1;var a=this.getImageLauncherSrc(n);if(l.getAttribute("src")!==a)return!1;l.style.opacity=i?"0":"1",i?l.setAttribute("aria-hidden","true"):l.removeAttribute("aria-hidden");var s=r.querySelector("[".concat(nt,"]"));if(i&&!s){var c=document.createElement("div");c.setAttribute(nt,""),Object.assign(c.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center"}),this.appendChevronSvg(c,Math.round(.5*e)),r.appendChild(c)}return!i&&(null==s?void 0:s.parentElement)&&s.parentElement.removeChild(s),!0},e.prototype.createLauncherElement=function(){var e,n,t=this.config,o=t.config,i=t.isIframeVisible,r=O().copilotUrl,l=null!==(e=null==o?void 0:o.launcher_size_multiplier)&&void 0!==e?e:1,a=null!==(n=this.config.launcher_size)&&void 0!==n?n:48*l;switch(o.launcher_type){case f.TEXT:return this.createTextLauncher();case f.TEXTUAL_IMAGE:return this.createTextualImageLauncher();case f.IMAGE:default:var s=document.createElement("div");s.setAttribute(et,""),Object.assign(s.style,{position:"relative",width:"100%",height:"100%"});var c=document.createElement("img");if(c.src=this.getImageLauncherSrc(r),c.alt="Chat",i&&c.setAttribute("aria-hidden","true"),Object.assign(c.style,{zIndex:"1000",cursor:"pointer",borderRadius:"50%",objectFit:"cover",width:"100%",height:"100%",boxSizing:"border-box",position:"absolute",inset:"0",opacity:i?"0":"1"}),s.appendChild(c),i){var d=document.createElement("div");d.setAttribute(nt,""),Object.assign(d.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center"}),this.appendChevronSvg(d,Math.round(.5*a)),s.appendChild(d)}return s}},e.prototype.createTextLauncher=function(){var e=this.config.config,n=e.brand_colour,t=e.launcher_properties,o=e.launcher_size_multiplier,i=null!=o?o:1,r=void 0!==this.config.launcher_size?void 0:160*i,l=void 0!==this.config.launcher_size?void 0:40*i,a=void 0!==this.config.launcher_size?void 0:14*i,s=void 0!==this.config.launcher_size?void 0:21*i,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!==l?"".concat(l,"px"):"40px",borderRadius:"9999px",backgroundColor:n,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:I(n),fontSize:void 0!==a?"".concat(a,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==s?"".concat(s,"px"):N,fontFamily:R,textAlign:"center",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),u.textContent=(null==t?void 0:t.text)||"",d.appendChild(u),c.appendChild(d),c},e.prototype.createTextualImageLauncher=function(){var e,n,t,o,i,r,l=O().copilotUrl,a=this.config.config,s=a.brand_colour,c=a.launcher_properties,d=a.image_url,u=a.launcher_size_multiplier,p=null!=u?u:1,f=void 0!==this.config.launcher_size?void 0:174*p,h=void 0!==this.config.launcher_size?void 0:40*p,v=void 0!==this.config.launcher_size?void 0:40*p,m=void 0!==this.config.launcher_size?void 0:14*p,g=void 0!==this.config.launcher_size?void 0:21*p,_=document.createElement("div");Object.assign(_.style,{maxWidth:void 0!==f?"".concat(f,"px"):"13rem",width:"fit-content",height:void 0!==h?"".concat(h,"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 b=document.createElement("div");Object.assign(b.style,{flex:"1",minWidth:"0"});var y=document.createElement("p");Object.assign(y.style,{margin:"0",color:I(s),fontSize:void 0!==m?"".concat(m,"px"):"0.875rem",fontWeight:"600",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:void 0!==g?"".concat(g,"px"):N,fontFamily:R,textAlign:"right",WebkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",textSizeAdjust:"100%"}),y.textContent=(null==c?void 0:c.text)||"";var w=document.createElement("div");Object.assign(w.style,{width:void 0!==v?"".concat(v,"px"):"40px",height:void 0!==v?"".concat(v,"px"):"40px",borderRadius:"9999px",overflow:"hidden",position:"relative",flexShrink:"0"});var E=document.createElement("img");return E.src=(null===(n=null===(e=null==this?void 0:this.config)||void 0===e?void 0:e.config)||void 0===n?void 0:n.launcher_type)?(null===(r=null===(i=null===(o=null===(t=null==this?void 0:this.config)||void 0===t?void 0:t.config)||void 0===o?void 0:o.images)||void 0===i?void 0:i.launcher_image_url)||void 0===r?void 0:r.url)||"".concat(l,"/chatbubble.png"):d||"".concat(l,"/chatbubble.png"),E.alt="Chat",Object.assign(E.style,{width:"100%",height:"100%",objectFit:"cover"}),b.appendChild(y),w.appendChild(E),_.appendChild(b),_.appendChild(w),_},e.prototype.applyResponsiveStyles=function(e){var n,t,o,i,r,l,a,s,c,d=(null===window||void 0===window?void 0:window.innerWidth)<560,u=this.config.config,p=this.config.position||(null===(o=u.interface_properties)||void 0===o?void 0:o.position)||"Right",f=null!==(l=null!==(i=this.config.sideSpacing)&&void 0!==i?i:null===(r=u.interface_properties)||void 0===r?void 0:r.side_spacing)&&void 0!==l?l:20,h=null!==(c=null!==(a=this.config.bottomSpacing)&&void 0!==a?a:null===(s=u.interface_properties)||void 0===s?void 0:s.bottom_spacing)&&void 0!==c?c:20;this.buttonElement.style.position="",this.buttonElement.style.bottom="",this.buttonElement.style.right="",this.buttonElement.style.left="";var v=b(b({},e),d?((n={position:"fixed",bottom:"".concat(h,"px")})[p.toLowerCase()]="".concat(f,"px"),n):((t={bottom:"".concat(h,"px")})[p.toLowerCase()]="".concat(f,"px"),t));Object.assign(this.buttonElement.style,v)},e.prototype.handleResize=function(){var e,n,t,o=null!==(n=null===(e=this.config.config)||void 0===e?void 0:e.launcher_size_multiplier)&&void 0!==n?n:1,i=null!==(t=this.config.launcher_size)&&void 0!==t?t:48*o,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!==f.IMAGE?"9999px":"50%",boxSizing:"border-box"};this.config.config.launcher_type===f.IMAGE&&Object.assign(r,{width:"".concat(i,"px"),height:"".concat(i,"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 n,t;null===(t=(n=e.config).onEvent)||void 0===t||t.call(n,{type:x.CHATBOT_BUTTON_LOADED,timestamp:Date.now()}),e.config.onInternalEvent(x.CHATBOT_BUTTON_LOADED)}))},e.prototype.update=function(e){this.config.isIframeVisible,this.config=b(b({},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=[],this.scrollHandlers.forEach((function(e){window.removeEventListener("scroll",e)})),this.scrollHandlers.clear(),this.shownScrollMessages.clear()},e.prototype.hideProactiveMessages=function(){var e,n,t=this;V();var o=null===(e=this.proactiveElement)||void 0===e?void 0:e.children[0];if(o){var i="Right"===(this.config.position||(null===(n=this.config.config.interface_properties)||void 0===n?void 0:n.position)||"Right");Array.from(o.children).forEach((function(e){e.className=i?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){t.proactiveElement&&t.proactiveElement.parentElement&&t.proactiveElement.parentElement.removeChild(t.proactiveElement),t.proactiveElement=null,t.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(R,' !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 n,t,o,i,r,l,a,s,c,d,u,p,h,v,m,g=this,b=null===(t=null===(n=this.config)||void 0===n?void 0:n.config)||void 0===t?void 0:t.proactive_message_obj;if(Array.isArray(b)&&!this.config.isIframeVisible&&!G()){if(this.injectAnimationStyles(),!this.proactiveElement){var y=document.createElement("div");y.style.position="fixed";var w=null!==(l=null!==(i=this.config.bottomSpacing)&&void 0!==i?i:null===(r=this.config.config.interface_properties)||void 0===r?void 0:r.bottom_spacing)&&void 0!==l?l:20,T=null!==(c=null!==(a=this.config.sideSpacing)&&void 0!==a?a:null===(s=this.config.config.interface_properties)||void 0===s?void 0:s.side_spacing)&&void 0!==c?c:20,S=this.config.position||(null===(d=this.config.config.interface_properties)||void 0===d?void 0:d.position)||"Right",x=null!==(p=null===(u=this.config.config)||void 0===u?void 0:u.launcher_size_multiplier)&&void 0!==p?p:1,A=null!==(h=this.config.launcher_size)&&void 0!==h?h:48*x,C=this.config.config.launcher_type===f.IMAGE?A:void 0!==this.config.launcher_size?40:40*x;y.style.bottom="".concat(w+C+8,"px"),"Right"===S?y.style.right="".concat(T,"px"):y.style.left="".concat(T,"px"),y.style.maxWidth="22.875rem",y.style.zIndex="2147483646";var O=document.createElement("div");O.style.display="flex",O.style.flexDirection="column",O.style.alignItems="Right"===S?"flex-end":"flex-start";var D=document.createElement("div");D.style.position="absolute",D.style.top="-32px",D.style.width="24px",D.style.height="24px",D.style.borderRadius="50%",D.style.background="#fff",D.style.boxShadow="0 2.667px 2.667px 0 rgba(0, 0, 0, 0.25)",D.style.display="flex",D.style.alignItems="center",D.style.justifyContent="center",D.style.cursor="pointer",D.style.opacity="0",D.style.visibility="hidden","Right"===(this.config.position||(null===(v=this.config.config.interface_properties)||void 0===v?void 0:v.position)||"Right")?(D.style.right="0px",D.style.left="auto",D.style.transform="translateX(120%) scale(0.95)"):(D.style.left="0px",D.style.right="auto",D.style.transform="translateX(-120%) scale(0.95)"),D.onclick=function(e){e.stopPropagation(),g.hideProactiveMessages()},D.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 ',y.appendChild(O),y.appendChild(D),document.body.appendChild(y),this.proactiveElement=y}var L=this.proactiveElement.children[0];L.innerHTML="";var k="Right"===(this.config.position||(null===(m=this.config.config.interface_properties)||void 0===m?void 0:m.position)||"Right");L.style.display="flex",L.style.flexDirection="column",L.style.alignItems=k?"flex-end":"flex-start",this.clearProactiveDelays();var M=J(b),z=[],P=[];M.forEach((function(e){"scroll"===e.delayType&&void 0!==e.scrollThreshold&&Number(e.scrollThreshold)>0?P.push(e):z.push(e)}));var H=new Map;z.forEach((function(e){var n=H.get(e.delayMs);n||(n={messageIds:[],groups:new Map},H.set(e.delayMs,n)),n.groups.has(e.messageId)||(n.messageIds.push(e.messageId),n.groups.set(e.messageId,[])),n.groups.get(e.messageId).push(e)}));var F=new Map;P.forEach((function(e){var n=e.scrollThreshold||0,t=F.get(n);t||(t={messageIds:[],groups:new Map},F.set(n,t)),t.groups.has(e.messageId)||(t.messageIds.push(e.messageId),t.groups.set(e.messageId,[])),t.groups.get(e.messageId).push(e)}));var U=void 0!==H.get(0),B=this.proactiveElement.children[1];if(B&&M.length>0){B.style.opacity="0",B.style.visibility="hidden",B.style.transform=k?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var W=function(){if(B){B.style.visibility="visible";var e=L.children.length,n=e>0?10*(e-1):0;B.style.animationDelay="".concat(n,"ms"),B.className=k?"rblyn-proactive-close-enter-right":"rblyn-proactive-close-enter-left"}};if(U){var j=window.setTimeout(W,0);this.delayTimers.push(j)}else{var V=Math.min.apply(Math,Array.from(H.keys()));j=window.setTimeout(W,V);this.delayTimers.push(j)}}else B&&(B.style.opacity="0",B.style.visibility="hidden");var K=function(e,n,t){var o=L.children.length,i=0,r=[];e.forEach((function(e){var t=n.get(e)||[];E([],t,!0).sort((function(e,n){return e.contentIndex-n.contentIndex})).forEach((function(n){r.push({messageId:e,item:n})})),i+=t.length}));var l=t>0?E([],r,!0).reverse():r;l.forEach((function(e,n){var r,a=e.item,s=document.createElement("div"),c=a.messageDisplayType===_.BUTTON;s.style.background=(null==a?void 0:a.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=R,s.style.fontSize="14px",s.style.lineHeight=String(N),s.style.width="fit-content",s.style.maxWidth="100%";var d=0===n,u=n===l.length-1,p=o>0,f=H.has(0),h=!1;0===t?h=!u||d&&p:d&&(p||f)?h=!0:d||(h=!0),h&&(s.style.marginBottom="16px");var v=10*(o+i-1-(0===t?o+0:0));s.className=k?"rblyn-proactive-enter-right":"rblyn-proactive-enter-left",s.style.animationDelay="".concat(v,"ms"),s.style.opacity="0",s.style.transform=k?"translateX(120%) scale(0.95)":"translateX(-120%) scale(0.95)";var m=document.createElement("div");Object.assign(m.style,{display:"flex",alignItems:"center",gap:"8px"});var b=document.createElement("div");if(b.className="rblyn-proactive-message-content",b.setAttribute("dir",on(a.html)),b.innerHTML=tn(a.html),m.appendChild(b),(null==a?void 0:a.urlToGo)&&"string"==typeof a.urlToGo&&""!==a.urlToGo.trim()){var y=document.createElementNS("http://www.w3.org/2000/svg","svg");y.setAttribute("width","16"),y.setAttribute("height","17"),y.setAttribute("viewBox","0 0 16 17"),y.setAttribute("fill","none"),y.setAttribute("xmlns","http://www.w3.org/2000/svg"),Object.assign(y.style,{flexShrink:"0",color:I((null==a?void 0:a.messageBubbleBg)||"#ffffff")});var w=document.createElementNS("http://www.w3.org/2000/svg","g");w.setAttribute("id","External_Link");var E=document.createElementNS("http://www.w3.org/2000/svg","path");E.setAttribute("id","Vector"),E.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"),E.setAttribute("stroke","currentColor"),E.setAttribute("stroke-width","1.5"),E.setAttribute("stroke-linecap","round"),E.setAttribute("stroke-linejoin","round"),w.appendChild(E),y.appendChild(w),m.appendChild(y)}if(s.appendChild(m),s.onclick=function(){if((null==a?void 0:a.urlToGo)&&"string"==typeof a.urlToGo&&""!==a.urlToGo.trim())window.open(a.urlToGo,"_blank","noopener,noreferrer");else{Y({message_id:a.messageId,content_string:a.html||null,content_id:a.contentId||null}),g.config.toggleIframe(),g.hideProactiveMessages();try{window.dispatchEvent(new CustomEvent("rblyn:proactiveClick",{detail:{message_id:a.messageId,content_string:a.html||null,content_id:a.contentId||null}}))}catch(e){}}},0===t)L.appendChild(s);else{L.insertBefore(s,L.firstChild);var T=null===(r=g.proactiveElement)||void 0===r?void 0:r.children[1];if(T&&"visible"===T.style.visibility){var S=L.children.length,x=S>0?10*(S-1):0;T.style.animationDelay="".concat(x,"ms")}}}))};H.forEach((function(e,n){var t=e.messageIds,o=e.groups;if(0===n)K(t,o,n);else{var i=window.setTimeout((function(){K(t,o,n)}),n);g.delayTimers.push(i)}})),F.forEach((function(e,n){var t=e.messageIds,o=e.groups,i="scroll-".concat(n),r=function(){if((window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=n&&!g.shownScrollMessages.has(i)){g.shownScrollMessages.add(i),K(t,o,1);var e=g.scrollHandlers.get(i);e&&(window.removeEventListener("scroll",e),g.scrollHandlers.delete(i))}};r(),g.scrollHandlers.set(i,r),window.addEventListener("scroll",r,{passive:!0})}))}else if(this.proactiveElement&&this.proactiveElement.parentElement){var X=this.proactiveElement.children[0],q="Right"===(this.config.position||(null===(o=this.config.config.interface_properties)||void 0===o?void 0:o.position)||"Right");Array.from(X.children).forEach((function(e){e.className=q?"rblyn-proactive-exit-right":"rblyn-proactive-exit-left"})),setTimeout((function(){g.proactiveElement&&g.proactiveElement.parentElement&&g.proactiveElement.parentElement.removeChild(g.proactiveElement),g.proactiveElement=null,g.clearProactiveDelays()}),400)}else this.proactiveElement=null,this.clearProactiveDelays()},e}(),ot=function(){function e(e){var n=this;this.isInitialized=!1,this.hasRegistered=!1,this.isAppReady=!1,this.shouldWaitForAppReady=!1,this.hasPendingOpenRequest=!1,this.overridesPayloadCache=null,this.proactiveDataSentInRegistration=!1,this.openedDueToProactive=!1,this.handleMessage=function(e){var t,o,i,r,l,a,s,c,d,u,p=O().copilotUrl;if(e.origin===p){var f=JSON.parse(e.data);if("APP_READY"===(null==f?void 0:f.type))return n.isAppReady=!0,void n.sendOpenAndRegisterIfReady();if("CHATBOT_CLOSED"===(null==f?void 0:f.type))return void(null===(t=null==n?void 0:n.config)||void 0===t||t.onClose());if("CHATBOT_TOKEN_EXHAUSTED"===(null==f?void 0:f.type))return void n.config.onInternalEvent(A.CHATBOT_TOKEN_EXHAUSTED);"CHATBOT_LOADED"===(null==f?void 0:f.type)&&(null===(i=(o=n.config).onEvent)||void 0===i||i.call(o,{type:x.CHATBOT_LOADED,timestamp:Date.now()}),n.config.onInternalEvent(x.CHATBOT_LOADED)),"CHAT_INITIALIZED"===(null==f?void 0:f.type)&&(null===(l=(r=n.config).onEvent)||void 0===l||l.call(r,{type:x.CHAT_INITIALIZED,timestamp:Date.now()}),n.config.onInternalEvent(x.CHAT_INITIALIZED)),"CHAT_INITIALIZATION_FAILED"===(null==f?void 0:f.type)&&(null===(s=(a=n.config).onEvent)||void 0===s||s.call(a,{type:x.CHAT_INITIALIZATION_FAILED,timestamp:Date.now()}),n.config.onInternalEvent(x.CHAT_INITIALIZATION_FAILED,{error:null===(c=e.data)||void 0===c?void 0:c.error})),"SESSION_REFRESHED"===(null==f?void 0:f.type)&&(null===(u=(d=n.config).onEvent)||void 0===u||u.call(d,{type:x.SESSION_REFRESHED,timestamp:Date.now()}),n.config.onInternalEvent(x.SESSION_REFRESHED)),"CHAT_MOVED"===(null==f?void 0:f.type)&&n.config.onInternalEvent(A.CHAT_MOVED,{from:e.data.from,to:e.data.to,trigger:e.data.trigger})}},this.config=e,this.iframeElement=document.createElement("iframe"),this.iframeElement.id="chat-iframe-rbyln",this.resizeHandler=this.applyResponsiveStyles.bind(this),this.render(),this.initialize(),this.setupEventListeners()}return e.prototype.buildOverridesPayload=function(){var e,n,t,o,i,r,l,a,s,c,d,u,p,f,h,v,m,g,_,b,y;return{header_avatar:null!==(t=null===(n=null===(e=this.config)||void 0===e?void 0:e.overrides)||void 0===n?void 0:n.header_avatar)&&void 0!==t?t:null,agent_avatar:null!==(r=null===(i=null===(o=this.config)||void 0===o?void 0:o.overrides)||void 0===i?void 0:i.agent_avatar)&&void 0!==r?r:null,header_title:null!==(s=null===(a=null===(l=this.config)||void 0===l?void 0:l.overrides)||void 0===a?void 0:a.header_title)&&void 0!==s?s:null,header_subtitle:null!==(u=null===(d=null===(c=this.config)||void 0===c?void 0:c.overrides)||void 0===d?void 0:d.header_subtitle)&&void 0!==u?u:null,header_title_text_color:null!==(h=null===(f=null===(p=this.config)||void 0===p?void 0:p.overrides)||void 0===f?void 0:f.header_title_text_color)&&void 0!==h?h:null,header_subtitle_text_color:null!==(g=null===(m=null===(v=this.config)||void 0===v?void 0:v.overrides)||void 0===m?void 0:m.header_subtitle_text_color)&&void 0!==g?g:null,header_bg:null!==(y=null===(b=null===(_=this.config)||void 0===_?void 0:_.overrides)||void 0===b?void 0:b.header_bg)&&void 0!==y?y:null}},e.prototype.hasUserProvidedOverrides=function(e){return Object.values(e).some((function(e){return"string"==typeof e?e.trim().length>0:null!=e}))},e.prototype.getElement=function(){return this.iframeElement},e.prototype.render=function(){var e,n=this.config.position||(null===(e=this.config.config.interface_properties)||void 0===e?void 0:e.position)||"Right";Object.assign(this.iframeElement.style,{zIndex:"20000000",border:"none",boxShadow:"0px 0px 40px 0px rgba(14, 14, 15, 0.24)",transformOrigin:"bottom ".concat(n.toLowerCase()),transition:"transform 0.2s cubic-bezier(0.2, 1.27, 0.29, 0.97), opacity 0.15s ease-out",transform:"scale(0.3) translate3d(0,40px,0)",opacity:"0",display:"none"}),this.applyResponsiveStyles()},e.prototype.applyResponsiveStyles=function(){var e,n,t,o,i,r;if(this.iframeElement){var l=this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right",a=null!==(r=null!==(o=this.config.bottomSpacing)&&void 0!==o?o:null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.bottom_spacing)&&void 0!==r?r:20;window.innerWidth<560?Object.assign(this.iframeElement.style,((e={width:"100vw",minWidth:"300px"})[l.toLowerCase()]="0",e.bottom="0",e.height="100vh",e.flexDirection="column",e.flexGrow="1",e.borderRadius="0",e.top="0",e.maxHeight="100%",e.position="fixed",e)):Object.assign(this.iframeElement.style,((n={width:"26%",minWidth:"400px",height:"calc(100vh - 2rem - 10vh - ".concat(a,"px)"),borderRadius:"1rem",top:"calc(10vh - 32px)",maxHeight:"50rem",position:""})[l.toLowerCase()]=void 0,n))}},e.prototype.initialize=function(){var e=this;if(!this.isInitialized){var n=O().copilotUrl;this.iframeElement.src="".concat(n,"/chatbot-plugin?id=").concat(this.config.config.chatbotId),this.isInitialized=!0,this.iframeElement.addEventListener("load",(function(){var t,o,i,r,l,a,s,c,d,u,p,f,h,v,m,g,_,y,w,E,I,T,S,A,C=new URL(e.iframeElement.src).origin||n;null===(t=e.iframeElement.contentWindow)||void 0===t||t.postMessage({domain:null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.hostname,name:"checkDomain"},C);var O=e.buildOverridesPayload();if(e.hasUserProvidedOverrides(O)&&(null===(i=e.iframeElement.contentWindow)||void 0===i||i.postMessage({domain:null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hostname,action:pn.UPDATE_OVERRIDES,data:O},n)),!e.hasRegistered&&e.iframeElement.contentWindow){e.iframeElement.contentWindow.postMessage({domain:null===(l=null===window||void 0===window?void 0:window.location)||void 0===l?void 0:l.hostname,action:pn.I_CAN_AUTHENTICATE,data:{show_history:null===(a=e.config.config)||void 0===a?void 0:a.show_history}},n);var D=K();e.proactiveDataSentInRegistration=!!D,e.iframeElement.contentWindow.postMessage({domain:null===(s=null===window||void 0===window?void 0:window.location)||void 0===s?void 0:s.hostname,action:pn.I_LOADED_LAUNCHER,data:b(b({ws_url:null===(c=e.config.config)||void 0===c?void 0:c.ws_url,userId:null===(d=e.config.config)||void 0===d?void 0:d.userId,token:null===(u=e.config.config)||void 0===u?void 0:u.token,userProfile:b(b({},null===(p=e.config.config)||void 0===p?void 0:p.userProfile),{__INT_SYS_INFO__:b(b({},(null===(h=null===(f=e.config.config)||void 0===f?void 0:f.userProfile)||void 0===h?void 0:h.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null===(v=e.config.config)||void 0===v?void 0:v.isAnonymous},D?{proactiveData:D}:{}),{show_history:null===(m=e.config.config)||void 0===m?void 0:m.show_history,init_load_image:(null===(y=null===(_=null===(g=e.config.config)||void 0===g?void 0:g.images)||void 0===_?void 0:_.header_image_url)||void 0===y?void 0:y.url)||(null===(w=e.config.config)||void 0===w?void 0:w.brand_logo_url),init_load_bot_name:null===(E=e.config.config)||void 0===E?void 0:E.name})},n),e.hasRegistered=!0}null===(T=(I=e.config).onIframeLoaded)||void 0===T||T.call(I),null===(A=(S=e.config).onEvent)||void 0===A||A.call(S,{type:x.CHATBOT_READY,timestamp:Date.now()}),e.config.onInternalEvent(x.CHATBOT_LOADED)}))}},e.prototype.setupEventListeners=function(){var e=this;window.addEventListener("resize",this.resizeHandler),this.iframeElement.addEventListener("error",(function(){mn.trackError(new Error(Nn[Sn]({src:e.iframeElement.src,error:"Failed to load iframe"})),"ChatbotIframe",{errorCode:Sn,errorType:Dn,context:{config:e.config.config,iframeUrl:e.iframeElement.src,timestamp:Date.now()}})})),window.addEventListener("message",this.handleMessage);window.addEventListener("rblyn:proactiveClick",(function(n){var t,o,i,r,l,a,s,c,d,u;if(e.hasRegistered)if(e.proactiveDataSentInRegistration)e.proactiveDataSentInRegistration=!1;else{e.openedDueToProactive=!0;var p=(null==n?void 0:n.detail)||{},f=O().copilotUrl,h=new URL(e.iframeElement.src).origin||f;null===(t=e.iframeElement.contentWindow)||void 0===t||t.postMessage({domain:null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.hostname,action:pn.I_CLICKED_PROACTIVE_BUBBLE,data:{userId:null===(i=e.config.config)||void 0===i?void 0:i.userId,token:null===(r=e.config.config)||void 0===r?void 0:r.token,userProfile:b(b({},null===(l=e.config.config)||void 0===l?void 0:l.userProfile),{__INT_SYS_INFO__:b(b({},(null===(s=null===(a=e.config.config)||void 0===a?void 0:a.userProfile)||void 0===s?void 0:s.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null===(c=e.config.config)||void 0===c?void 0:c.isAnonymous,ws_url:null===(d=e.config.config)||void 0===d?void 0:d.ws_url,proactiveData:{input_id:null,message_id:(null==p?void 0:p.message_id)||null,content_string:(null==p?void 0:p.content_string)||null,content_id:(null==p?void 0:p.content_id)||null},show_history:null===(u=e.config.config)||void 0===u?void 0:u.show_history}},h)}}))},e.prototype.updateVisibility=function(e,n){var t;this.shouldWaitForAppReady=!!n,this.config.isVisible=e;var o=this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right";if(e?this.showIframe(o):this.hideIframe(o),!e)return this.openedDueToProactive=!1,void(this.hasPendingOpenRequest=!1);this.hasPendingOpenRequest=!0,this.shouldWaitForAppReady,this.sendOpenAndRegisterIfReady()},e.prototype.showIframe=function(e){this.iframeElement.style.display="block",this.iframeElement.getBoundingClientRect(),this.iframeElement.style.opacity="1",this.iframeElement.style.transform="scale(1) translate3d(0,0,0)"},e.prototype.hideIframe=function(e){var n=this;this.iframeElement.style.opacity="0",this.iframeElement.style.transform="scale(0.3) translate3d(".concat((e.toLowerCase(),"0"),",40px,0)"),setTimeout((function(){n.config.isVisible||(n.iframeElement.style.display="none")}),200)},e.prototype.sendOpenAndRegisterIfReady=function(){var e,n,t,o,i,r,l,a,s,c,d,u;if(this.iframeElement.contentWindow&&this.config.isVisible&&(!this.shouldWaitForAppReady||this.isAppReady)&&this.hasPendingOpenRequest){var p=O().copilotUrl,f=new URL(this.iframeElement.src).origin||p;if(this.iframeElement.contentWindow.postMessage({domain:null===(e=null===window||void 0===window?void 0:window.location)||void 0===e?void 0:e.hostname,name:"openFrame"},f),this.openedDueToProactive)this.openedDueToProactive=!1;else{var h=K();this.iframeElement.contentWindow.postMessage({domain:null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.hostname,action:pn.I_OPENED_IFRAME,data:b(b({ws_url:null===(t=this.config.config)||void 0===t?void 0:t.ws_url,userId:null===(o=this.config.config)||void 0===o?void 0:o.userId,token:null===(i=this.config.config)||void 0===i?void 0:i.token,userProfile:b(b({},null===(r=this.config.config)||void 0===r?void 0:r.userProfile),{__INT_SYS_INFO__:b(b({},(null===(a=null===(l=this.config.config)||void 0===l?void 0:l.userProfile)||void 0===a?void 0:a.__INT_SYS_INFO__)||{}),kn())}),isAnonymous:null===(s=this.config.config)||void 0===s?void 0:s.isAnonymous},h?{proactiveData:h}:{}),{show_history:null===(c=this.config.config)||void 0===c?void 0:c.show_history})},p)}null===(u=(d=this.config).onEvent)||void 0===u||u.call(d,{type:x.CHATBOT_OPENED,timestamp:Date.now()}),this.config.onInternalEvent(x.CHATBOT_OPENED),this.hasPendingOpenRequest=!1}},e.prototype.update=function(e,n){var t,o,i=this.config.isVisible;if(this.config=b(b({},this.config),e),i!==this.config.isVisible&&this.updateVisibility(this.config.isVisible,n),this.iframeElement.contentWindow&&this.config.isVisible){var r=O().copilotUrl;this.iframeElement.contentWindow.postMessage({action:pn.UPDATE_USER_PROFILE,user_profile:this.config.config.userProfile,show_history:null===(t=this.config.config)||void 0===t?void 0:t.show_history},r),this.iframeElement.contentWindow.postMessage({action:pn.OPENED_IFRAME_EVENT,user_profile:this.config.config.userProfile,show_history:null===(o=this.config.config)||void 0===o?void 0:o.show_history},r)}},e.prototype.destroy=function(){window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("message",this.handleMessage),this.iframeElement&&this.iframeElement.parentNode&&this.iframeElement.parentNode.removeChild(this.iframeElement)},e}(),it=function(){function e(e,n,t,o){this.resizeObserver=null,this.containerElement=document.createElement("div"),this.handleResizeFunction=this.handleResize.bind(this),this.config={config:e,position:n,sideSpacing:t,bottomSpacing:o},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,n,t,o,i,r,l,a,s,c=(null===window||void 0===window?void 0:window.innerWidth)<560,d=this.config.position||(null===(t=this.config.config.interface_properties)||void 0===t?void 0:t.position)||"Right",u=null!==(r=null!==(o=this.config.sideSpacing)&&void 0!==o?o:null===(i=this.config.config.interface_properties)||void 0===i?void 0:i.side_spacing)&&void 0!==r?r:20,p=null!==(s=null!==(l=this.config.bottomSpacing)&&void 0!==l?l:null===(a=this.config.config.interface_properties)||void 0===a?void 0:a.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 f={position:"fixed",zIndex:"1000",display:"flex",flexDirection:"column"},h=b(b({},f),((e={bottom:"".concat(p,"px")})[d.toLowerCase()]="".concat(u,"px"),e.alignItems="Right"===d?"flex-end":"flex-start",e)),v=b(b({},f),((n={top:"0"})[d.toLowerCase()]="".concat(u,"px"),n.alignItems="center",n));Object.assign(this.containerElement.style,c?v: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}(),rt=function(e){e.api_key,e.user_profile;var n=e.onEvent;e.chatbotConfig;return{emit:function(e,t){var o={type:e,timestamp:Date.now(),data:t};null==n||n(o)},onInternalEvent:function(e,n){}}},lt=function(){function e(e){var n=this;this.container=null,this.floatingButton=null,this.launcherDelayTimeout=null,this.iframe=null,this.isDestroyed=!1,this.isIframeLoaded=!1,this.hasScrolledPastDepth=!1,this.scrollHandler=null,this.hasAutoLaunched=!1,this.hasScrolledPastAutoLaunchDepth=!1,this.autoLaunchScrollHandler=null,this.autoLaunchDelayTimeout=null,this.handleStateChange=function(e){var t,o,i,r,l,a,s,c,d;if(!n.isDestroyed){var u=e.isInitialized,p=e.error,f=e.chatbotConfig,h=e.isIframeVisible;if(!p&&f&&u){if(n.eventEmitter=rt({api_key:n.config.api_key,user_profile:n.config.user_profile,onEvent:n.config.onEvent,chatbotConfig:{isAnonymous:f.isAnonymous,userId:f.userId}}),n.container||(n.container=new it(f,n.config.position,n.config.sideSpacing,n.config.bottomSpacing)),n.iframe)n.iframe.update({config:f,isVisible:h,position:n.config.position,bottomSpacing:n.config.bottomSpacing,overrides:n.config.overrides},!0);else if(n.iframe=new ot({config:f,isVisible:h,onClose:n.handleClose,onEvent:n.config.onEvent,onIframeLoaded:function(){n.isIframeLoaded=!0;var e=n.stateManager.getState();n.handleStateChange({isInitialized:e.isInitialized,error:e.error,chatbotConfig:e.chatbotConfig,isIframeVisible:e.isIframeVisible}),e.chatbotConfig&&n.handleAutoLaunch(e.chatbotConfig,e.isIframeVisible)},onInternalEvent:n.eventEmitter.onInternalEvent,position:n.config.position,bottomSpacing:n.config.bottomSpacing,overrides:n.config.overrides}),n.iframe.getElement&&"function"==typeof n.iframe.getElement){var v=n.iframe.getElement();v&&n.container&&n.container.getElement().prepend(v)}n.setupScrollTracking(f),n.setupAutoLaunchScrollTracking(f);var m=void 0!==n.config.show_launcher?Boolean(n.config.show_launcher):null===(t=null==f?void 0:f.show_launcher)||void 0===t||t,g=!0===(null===(o=null==f?void 0:f.launcher_delay)||void 0===o?void 0:o.enabled),_=null!==(a=null!==(r=null===(i=null==f?void 0:f.launcher_delay)||void 0===i?void 0:i.seconds)&&void 0!==r?r:null===(l=null==f?void 0:f.launcher_delay)||void 0===l?void 0:l.delay)&&void 0!==a?a:0,b=!0===(null===(s=null==f?void 0:f.launcher_scroll)||void 0===s?void 0:s.enabled),y=null!==(d=null===(c=null==f?void 0:f.launcher_scroll)||void 0===c?void 0:c.depth)&&void 0!==d?d:0,w=b&&Number(y)>0;console.log("[Vanilla SDK] Launcher visibility check",{finalShowLauncher:m,delayEnabled:g,seconds:_,scrollEnabled:b,scrollDepth:y,requiresScroll:w,hasScrolledPastDepth:n.hasScrolledPastDepth});var E=!0;if(w){var I=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;E=I>=Number(y)||n.hasScrolledPastDepth,console.log("[Vanilla SDK] Scroll condition check",{currentScrollY:I,requiredDepth:Number(y),hasScrolledPastDepthState:n.hasScrolledPastDepth,scrollConditionMet:E})}var T=function(){if(n.isIframeLoaded)if(n.floatingButton)n.floatingButton.update({config:f,isIframeVisible:h,position:n.config.position,sideSpacing:n.config.sideSpacing,bottomSpacing:n.config.bottomSpacing,launcher_size:n.config.launcher_size}),n.handleAutoLaunch(f,h);else{if(n.floatingButton=new tt({config:f,toggleIframe:n.toggleIframe,isIframeVisible:h,onEvent:n.config.onEvent,onInternalEvent:n.eventEmitter.onInternalEvent,position:n.config.position,sideSpacing:n.config.sideSpacing,bottomSpacing:n.config.bottomSpacing,launcher_size:n.config.launcher_size}),n.floatingButton.getElement&&"function"==typeof n.floatingButton.getElement){var e=n.floatingButton.getElement();e&&n.container&&n.container.getElement().appendChild(e)}n.handleAutoLaunch(f,h)}},S=function(){n.floatingButton&&(n.floatingButton.destroy(),n.floatingButton=null)};n.launcherDelayTimeout&&(clearTimeout(n.launcherDelayTimeout),n.launcherDelayTimeout=null),m?w&&!E?(console.log("[Vanilla SDK] Scroll required but condition not met, unmounting button"),S()):g&&Number(_)>0?n.floatingButton?n.isIframeLoaded&&T():n.launcherDelayTimeout=window.setTimeout((function(){var e,t,o,i=n.stateManager.getState().chatbotConfig,r=!0===(null===(e=null==i?void 0:i.launcher_scroll)||void 0===e?void 0:e.enabled),l=null!==(o=null===(t=null==i?void 0:i.launcher_scroll)||void 0===t?void 0:t.depth)&&void 0!==o?o:0,a=r&&Number(l)>0,s=!0;a&&(s=(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(l)||n.hasScrolledPastDepth);!n.isIframeLoaded||a&&!s||T(),n.launcherDelayTimeout=null}),1e3*Number(_)):(console.log("[Vanilla SDK] No delay, checking iframe loaded",{isIframeLoaded:n.isIframeLoaded}),n.isIframeLoaded?(console.log("[Vanilla SDK] Mounting button immediately"),T()):console.log("[Vanilla SDK] Iframe not loaded yet, button will mount when loaded")):(console.log("[Vanilla SDK] show_launcher is false, unmounting button"),S())}}},this.setupAutoLaunchScrollTracking=function(e){var t,o,i;if(e&&!n.hasAutoLaunched){var r=!0===(null===(t=null==e?void 0:e.auto_launch_scroll)||void 0===t?void 0:t.enabled),l=null!==(i=null===(o=null==e?void 0:e.auto_launch_scroll)||void 0===o?void 0:o.depth)&&void 0!==i?i:0;if(n.autoLaunchScrollHandler&&(window.removeEventListener("scroll",n.autoLaunchScrollHandler),n.autoLaunchScrollHandler=null),!r||Number(l)<=0)n.hasScrolledPastAutoLaunchDepth=!1;else{var a=function(){if(!n.hasScrolledPastAutoLaunchDepth&&(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(l)){n.hasScrolledPastAutoLaunchDepth=!0;var e=n.stateManager.getState();e.chatbotConfig&&n.handleAutoLaunch(e.chatbotConfig,e.isIframeVisible)}};a(),n.autoLaunchScrollHandler=a,window.addEventListener("scroll",n.autoLaunchScrollHandler,{passive:!0})}}},this.handleAutoLaunch=function(e,t){var o,i,r,l,a,s,c;if(e&&!n.hasAutoLaunched&&n.isIframeLoaded&&!t){var d=void 0!==n.config.show_launcher?Boolean(n.config.show_launcher):null===(o=null==e?void 0:e.show_launcher)||void 0===o||o,u=!0===(null==e?void 0:e.auto_launch),p=!!n.floatingButton;if(d&&u&&p){var f=!0===(null===(i=null==e?void 0:e.auto_launch_delay)||void 0===i?void 0:i.enabled),h=null!==(l=null===(r=null==e?void 0:e.auto_launch_delay)||void 0===r?void 0:r.seconds)&&void 0!==l?l:0,v=!0===(null===(a=null==e?void 0:e.auto_launch_scroll)||void 0===a?void 0:a.enabled),m=null!==(c=null===(s=null==e?void 0:e.auto_launch_scroll)||void 0===s?void 0:s.depth)&&void 0!==c?c:0,g=v&&Number(m)>0,_=!0;if(g)_=(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(m)||n.hasScrolledPastAutoLaunchDepth;if(!g||_){n.autoLaunchDelayTimeout&&(clearTimeout(n.autoLaunchDelayTimeout),n.autoLaunchDelayTimeout=null);var b=function(){n.hasAutoLaunched||t||(n.hasAutoLaunched=!0,n.toggleIframe(),n.eventEmitter.emit(x.CHATBOT_BUTTON_CLICKED))};f&&Number(h)>0?n.autoLaunchDelayTimeout=window.setTimeout((function(){var e=!0;g&&(e=(window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0)>=Number(m)||n.hasScrolledPastAutoLaunchDepth);g&&!e||b(),n.autoLaunchDelayTimeout=null}),1e3*Number(h)):b()}}}},this.setupScrollTracking=function(e){var t,o,i,r,l;if(console.log("[Vanilla SDK] setupScrollTracking called",{hasConfig:!!e,scrollEnabled:null===(t=null==e?void 0:e.launcher_scroll)||void 0===t?void 0:t.enabled,scrollDepth:null===(o=null==e?void 0:e.launcher_scroll)||void 0===o?void 0:o.depth}),e){var a=!0===(null===(i=null==e?void 0:e.launcher_scroll)||void 0===i?void 0:i.enabled),s=null!==(l=null===(r=null==e?void 0:e.launcher_scroll)||void 0===r?void 0:r.depth)&&void 0!==l?l:0;if(n.scrollHandler&&(window.removeEventListener("scroll",n.scrollHandler),n.scrollHandler=null),!a||Number(s)<=0)return console.log("[Vanilla SDK] Scroll disabled or depth <= 0, resetting state"),void(n.hasScrolledPastDepth=!1);var c=function(){if(!n.hasScrolledPastDepth){var e=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;if(console.log("[Vanilla SDK] Checking scroll depth",{currentScrollY:e,requiredDepth:Number(s),hasScrolledPast:e>=Number(s),currentState:n.hasScrolledPastDepth}),e>=Number(s)){console.log("[Vanilla SDK] Scroll depth reached! Setting flag to true"),n.hasScrolledPastDepth=!0;var t=n.stateManager.getState();n.handleStateChange({isInitialized:t.isInitialized,error:t.error,chatbotConfig:t.chatbotConfig,isIframeVisible:t.isIframeVisible})}}};console.log("[Vanilla SDK] Checking initial scroll position"),c(),n.scrollHandler=c,window.addEventListener("scroll",n.scrollHandler,{passive:!0})}},this.toggleIframe=function(){var e=n.stateManager.getState();n.stateManager.toggleIframeVisibility(),n.eventEmitter.emit(e.isIframeVisible?x.CHATBOT_CLOSED:x.CHATBOT_BUTTON_CLICKED)},this.handleClose=function(){n.stateManager.closeIframe(),n.eventEmitter.emit(x.CHATBOT_CLOSED)};var t=b(b({},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=t,Jn(),!e.api_key)throw mn.trackError(new Error(Nn[gn](e.api_key)),"RobylonChatbot",{errorCode:gn,errorType:Cn,context:{timestamp:Date.now()}}),new Error("API key is required");try{mn.initialize(e.api_key,e.user_id)}catch(e){mn.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot",{errorCode:wn,errorType:Cn,context:{timestamp:Date.now()}})}this.stateManager=function(e){var n={isInitialized:!1,isInitializing:!1,error:null,chatbotConfig:null,isIframeVisible:!1},t=[],o=function(e){n=b(b({},n),e),t.forEach((function(e){return e(n)}))};return{getState:function(){return n},initialize:function(){return y(void 0,void 0,void 0,(function(){var n,t,i;return w(this,(function(r){switch(r.label){case 0:if(!e.api_key)return mn.trackError(new Error(Nn[gn](e.api_key)),"ChatbotStateManager",{errorCode:gn,errorType:Cn,context:{timestamp:Date.now()}}),[2];o({isInitializing:!0}),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Gn(e)];case 2:return n=r.sent(),[4,new Promise((function(e,t){jn(n,(function(){o({isInitialized:!0,chatbotConfig:n}),e()}),(function(e){t(e)}))}))];case 3:return r.sent(),[3,6];case 4:return t=r.sent(),i=t instanceof Error?t.message:"Failed to initialize chatbot",o({error:i}),mn.trackError(t instanceof Error?t:new Error(i),"ChatbotStateManager",{errorCode:yn,errorType:Cn,context:{timestamp:Date.now()}}),[3,6];case 5:return o({isInitializing:!1}),[7];case 6:return[2]}}))}))},toggleIframeVisibility:function(){o({isIframeVisible:!n.isIframeVisible})},closeIframe:function(){o({isIframeVisible:!1})},updateState:o,subscribe:function(e){return t.push(e),function(){var n=t.indexOf(e);n>-1&&t.splice(n,1)}},unsubscribe:function(e){var n=t.indexOf(e);n>-1&&t.splice(n,1)}}}({api_key:e.api_key,user_id:e.user_id,user_token:e.user_token,user_profile:e.user_profile}),this.eventEmitter=rt({api_key:e.api_key,user_profile:e.user_profile,onEvent:e.onEvent,chatbotConfig:null}),this.initialize()}return e.prototype.initialize=function(){return y(this,void 0,void 0,(function(){var e;return w(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.stateManager.initialize()];case 1:return n.sent(),this.stateManager.subscribe(this.handleStateChange),this.handleStateChange(this.stateManager.getState()),[3,3];case 2:return e=n.sent(),mn.trackError(e instanceof Error?e:new Error(String(e)),"RobylonChatbot.initialize",{errorCode:yn,errorType:Cn,context:{timestamp:Date.now()}}),[3,3];case 3:return[2]}}))}))},e.prototype.show=function(){this.stateManager.getState().isIframeVisible||(this.stateManager.toggleIframeVisibility(),this.eventEmitter.emit(x.CHATBOT_BUTTON_CLICKED))},e.prototype.hide=function(){this.stateManager.getState().isIframeVisible&&(this.stateManager.closeIframe(),this.eventEmitter.emit(x.CHATBOT_CLOSED))},e.prototype.toggle=function(){this.toggleIframe()},e.prototype.destroy=function(){this.isDestroyed=!0,this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null),this.autoLaunchScrollHandler&&(window.removeEventListener("scroll",this.autoLaunchScrollHandler),this.autoLaunchScrollHandler=null),this.autoLaunchDelayTimeout&&(clearTimeout(this.autoLaunchDelayTimeout),this.autoLaunchDelayTimeout=null),this.floatingButton&&(this.floatingButton.destroy(),this.floatingButton=null),this.launcherDelayTimeout&&(clearTimeout(this.launcherDelayTimeout),this.launcherDelayTimeout=null),this.iframe&&(this.iframe.destroy(),this.iframe=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 at(e){return new lt(e)}if("undefined"!=typeof window){!function(){if("undefined"!=typeof window){var e=window,n=(null==e?void 0:e.RobylonChatbot)||(null==e?void 0:e.R);if(n&&Array.isArray(n.q)){var t=null;n.q.forEach((function(e){var n=e[0];if("init"===n){var o=e[1]||{};t=at(o)}else t&&"function"==typeof t[n]&&t[n]()})),e.RobylonChatbot=function(e){var n=Array.prototype.slice.call(arguments,1);return"init"===e?t=at(n[0]||{}):t&&"function"==typeof t[e]?t[e].apply(t,n):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 st=window,ct=null==st?void 0:st.RobylonChatbot;ct&&!(null==st?void 0:st.R)&&(st.R=ct)}var dt={create:at,getState:function(){return"initialized"}};export{Qn as Chatbot,u as ChatbotInterfaceType,g as ConditionType,v as DisplayAttributesType,f as LauncherType,m as LogicalConditionType,_ as MessageDisplayType,h as ProactiveSendTimeType,dt as RobylonChatbot,p as WidgetPositionEnums,$n as useChatbot};
4
4
  //# sourceMappingURL=index.js.map