UNPKG

besper-frontend-toolkit-prod-main

Version:

Professional B-esper Frontend Toolkit - Modular bot integration for WordPress plugins and web applications

2 lines 670 kB
function e(){return"https://apimprodmainpublic.azure-api.net"}const t={botOperations:"/api/bot-operations",botManagement:"/api/bot-management",root:"/api",management:"/mgmt"};function n(e="botOperations"){const n=`https://apimprodmainpublic.azure-api.net${t[e]||t.botOperations}`.replace(/\/+/g,"/").replace("http:/","http://").replace("https:/","https://");return"undefined"!=typeof window&&window.location?.hostname?.includes("localhost"),n}function i(){return n("botOperations")}function o(){return n("botManagement")}function s(){return n("root")}async function a(e,t="GET",n=null,i={}){const o={method:t,headers:{"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest","Cache-Control":"no-cache",Pragma:"no-cache",...i}};n&&"GET"!==t&&(o.body=JSON.stringify(n));"undefined"!=typeof window&&(window.location?.hostname?.includes("localhost")||window.location?.search?.includes("debug=true"));try{const t=await fetch(e,o);if(!t.ok){let e=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.text();n&&(e+=` - ${n}`)}catch(e){}throw new Error(e)}return await t.json()}catch(e){throw e}}async function r(e,t="GET",n=null,i={}){return a(`${o()}/${e}`.replace(/\/+/g,"/").replace("http:/","http://").replace("https:/","https://"),t,n,i)}async function l(e,t="GET",n=null,o={}){return a(`${i()}/${e}`.replace(/\/+/g,"/").replace("http:/","http://").replace("https:/","https://"),t,n,o)}var d=Object.freeze({__proto__:null,API_PATHS:t,apiCall:a,getApiEndpoint:i,getBaseAPIEndpoint:e,getBotManagementEndpoint:o,getBotOperationsEndpoint:i,getManagementEndpoint:o,getRootApiEndpoint:s,getServiceEndpoint:n,managementApiCall:r,operationsApiCall:l});const c={typeYourMessage:{en:"Type your message here...",de:"Geben Sie hier Ihre Nachricht ein...",fr:"Tapez votre message ici...",es:"Escribe tu mensaje aquí...",it:"Digita il tuo messaggio qui...",pt:"Digite sua mensagem aqui...",nl:"Typ hier uw bericht...",pl:"Wpisz tutaj swoją wiadomość...",sv:"Skriv ditt meddelande här...",da:"Skriv din besked her...",fi:"Kirjoita viestisi tähän...",no:"Skriv meldingen din her...",cs:"Zde napište svou zprávu...",hu:"Írja ide üzenetét...",ro:"Introduceți mesajul aici...",sk:"Sem napíšte svoju správu...",hr:"Ovdje unesite poruku...",bg:"Въведете съобщението си тук...",sl:"Tukaj vnesite svoje sporočilo...",et:"Sisestage oma sõnum siia...",lv:"Ievadiet savu ziņu šeit...",lt:"Čia įveskite savo žinutę...",el:"Πληκτρολογήστε το μήνυμά σας εδώ...",ru:"Введите ваше сообщение здесь...",uk:"Введіть ваше повідомлення тут...",ja:"ここにメッセージを入力してください...",zh:"在此输入您的消息...",ko:"여기에 메시지를 입력하세요...",ar:"اكتب رسالتك هنا...",hi:"अपना संदेश यहाँ टाइप करें...",id:"Ketik pesan Anda di sini...",tr:"Mesajınızı buraya yazın...",th:"พิมพ์ข้อความของคุณที่นี่...",vi:"Nhập tin nhắn của bạn tại đây...",he:"הקלד את ההודעה שלך כאן...",fa:"پیام خود را اینجا تایپ کنید...",ms:"Taip mesej anda di sini...",tl:"I-type ang inyong mensahe dito..."},tapToStartChat:{en:"Tap to start chatting",de:"Tippen, um zu chatten",fr:"Appuyez pour discuter",es:"Toca para chatear",it:"Tocca per chattare",pt:"Toque para conversar",nl:"Tik om te chatten",pl:"Dotknij, aby rozmawiać",sv:"Tryck för att chatta",da:"Tryk for at chatte",fi:"Napauta keskustellaksesi",no:"Trykk for å chatte",cs:"Klepněte pro chat",hu:"Érintse meg a csevegéshez",ro:"Atingeți pentru a conversa",sk:"Ťuknite pre chat",hr:"Dodirnite za razgovor",bg:"Докоснете, за да чатите",sl:"Tapnite za klepet",et:"Puudutage vestlemiseks",lv:"Pieskarieties, lai tērzētu",lt:"Bakstelėkite norėdami kalbėtis",el:"Πατήστε για συνομιλία",ru:"Нажмите, чтобы начать чат",uk:"Торкніться, щоб почати чат",ja:"タップしてチャットを開始",zh:"点击开始聊天",ko:"채팅을 시작하려면 탭하세요",ar:"اضغط لبدء الدردشة",hi:"चैट शुरू करने के लिए टैप करें",id:"Ketuk untuk mulai mengobrol",tr:"Sohbete başlamak için dokunun",th:"แตะเพื่อเริ่มแชท",vi:"Chạm để bắt đầu trò chuyện",he:"הקש כדי להתחיל לשוחח",fa:"برای شروع چت ضربه بزنید",ms:"Ketuk untuk mula berbual",tl:"I-tap upang magsimulang mag-chat"},tooltips:{downloadConversation:{en:"Download Conversation",de:"Unterhaltung herunterladen",fr:"Télécharger la conversation",es:"Descargar conversación",it:"Scarica conversazione",pt:"Baixar conversa",nl:"Gesprek downloaden",pl:"Pobierz rozmowę",sv:"Ladda ner konversation",da:"Download samtale",fi:"Lataa keskustelu",no:"Last ned samtale",cs:"Stáhnout konverzaci",hu:"Beszélgetés letöltése",ro:"Descarcă conversația",sk:"Stiahnuť konverzáciu",hr:"Preuzmi razgovor",bg:"Изтегли разговор",sl:"Prenesi pogovor",et:"Laadi alla vestlus",lv:"Lejupielādēt sarunu",lt:"Atsisiųsti pokalbį",el:"Λήψη συνομιλίας",ru:"Скачать беседу",uk:"Завантажити розмову",ja:"会話をダウンロード",zh:"下载对话",ko:"대화 다운로드",ar:"تحميل المحادثة",hi:"बातचीत डाउनलोड करें",id:"Unduh Percakapan",tr:"Konuşmayı İndir",th:"ดาวน์โหลดการสนทนา",vi:"Tải cuộc trò chuyện",he:"הורד שיחה",fa:"دانلود مکالمه",ms:"Muat turun Perbualan",tl:"I-download ang Pag-uusap"},restartConversation:{en:"Restart Conversation",de:"Unterhaltung neu starten",fr:"Redémarrer la conversation",es:"Reiniciar conversación",it:"Riavvia conversazione",pt:"Reiniciar conversa",nl:"Gesprek herstarten",pl:"Uruchom ponownie rozmowę",sv:"Starta om konversation",da:"Genstart samtale",fi:"Aloita keskustelu uudelleen",no:"Start samtale på nytt",cs:"Restartovat konverzaci",hu:"Beszélgetés újraindítása",ro:"Repornește conversația",sk:"Reštartovať konverzáciu",hr:"Ponovno pokreni razgovor",bg:"Рестартирай разговор",sl:"Ponovno zaženi pogovor",et:"Taaskäivita vestlus",lv:"Atsākt sarunu",lt:"Paleisti pokalbį iš naujo",el:"Επανεκκίνηση συνομιλίας",ru:"Перезапустить беседу",uk:"Перезапустити розмову",ja:"会話を再開",zh:"重新开始对话",ko:"대화 재시작",ar:"إعادة تشغيل المحادثة",hi:"बातचीत पुनः आरंभ करें",id:"Mulai Ulang Percakapan",tr:"Konuşmayı Yeniden Başlat",th:"เริ่มการสนทนาใหม่",vi:"Khởi động lại cuộc trò chuyện",he:"הפעל מחדש שיחה",fa:"راه اندازی مجدد مکالمه",ms:"Mulakan semula Perbualan",tl:"Simulan muli ang Pag-uusap"},deleteConversation:{en:"Delete Conversation",de:"Unterhaltung löschen",fr:"Supprimer la conversation",es:"Eliminar conversación",it:"Elimina conversazione",pt:"Excluir conversa",nl:"Gesprek verwijderen",pl:"Usuń rozmowę",sv:"Radera konversation",da:"Slet samtale",fi:"Poista keskustelu",no:"Slett samtale",cs:"Smazat konverzaci",hu:"Beszélgetés törlése",ro:"Șterge conversația",sk:"Vymazať konverzáciu",hr:"Obriši razgovor",bg:"Изтрий разговор",sl:"Izbriši pogovor",et:"Kustuta vestlus",lv:"Dzēst sarunu",lt:"Ištrinti pokalbį",el:"Διαγραφή συνομιλίας",ru:"Удалить беседу",uk:"Видалити розмову",ja:"会話を削除",zh:"删除对话",ko:"대화 삭제",ar:"حذف المحادثة",hi:"बातचीत हटाएं",id:"Hapus Percakapan",tr:"Konuşmayı Sil",th:"ลบการสนทนา",vi:"Xóa cuộc trò chuyện",he:"מחק שיחה",fa:"حذف مکالمه",ms:"Padam Perbualan",tl:"Tanggalin ang Pag-uusap"},expandView:{en:"Optimize view for better readability",de:"Ansicht für bessere Lesbarkeit optimieren",fr:"Optimiser la vue pour une meilleure lisibilité",es:"Optimizar vista para mejor legibilidad",it:"Ottimizza vista per migliore leggibilità",pt:"Otimizar visualização para melhor legibilidade",nl:"Optimaliseer weergave voor betere leesbaarheid",pl:"Zoptymalizuj widok dla lepszej czytelności",sv:"Optimera vy för bättre läsbarhet",da:"Optimer visning for bedre læsbarhed",fi:"Optimoi näkymä parempaa luettavuutta varten",no:"Optimaliser visning for bedre lesbarhet",cs:"Optimalizovat zobrazení pro lepší čitelnost",hu:"Nézet optimalizálása a jobb olvashatóságért",ro:"Optimizează vizualizarea pentru o mai bună lizibilitate",sk:"Optimalizovať zobrazenie pre lepšiu čitateľnosť",hr:"Optimiziraj prikaz za bolju čitljivost",bg:"Оптимизирай изгледа за по-добра четимост",sl:"Optimiziraj pogled za boljšo berljivost",et:"Optimeeri vaade parema loetavuse jaoks",lv:"Optimizēt skatu labākai lasāmībai",lt:"Optimizuoti vaizdą geresniam skaitomumui",el:"Βελτιστοποίηση προβολής για καλύτερη αναγνωσιμότητα",ru:"Оптимизировать вид для лучшей читаемости",uk:"Оптимізувати вигляд для кращої читабельності",ja:"読みやすさのためにビューを最適化",zh:"优化视图以提高可读性",ko:"가독성을 위한 보기 최적화",ar:"تحسين العرض لقابلية قراءة أفضل",hi:"बेहतर पठनीयता के लिए दृश्य को अनुकूलित करें",id:"Optimalkan tampilan untuk keterbacaan yang lebih baik",tr:"Daha iyi okunabilirlik için görünümü optimize edin",th:"ปรับแต่งมุมมองเพื่อการอ่านที่ดีขึ้น",vi:"Tối ưu hóa chế độ xem để dễ đọc hơn",he:"אופטימיזציה של התצוגה לקריאה טובה יותר",fa:"بهینه سازی نمایش برای خوانایی بهتر",ms:"Optimalkan paparan untuk kebolehbacaan yang lebih baik",tl:"I-optimize ang view para sa mas magandang pagkakabasa"},minimizeChat:{en:"Minimize",de:"Minimieren",fr:"Réduire",es:"Minimizar",it:"Riduci",pt:"Minimizar",nl:"Minimaliseren",pl:"Minimalizuj",sv:"Minimera",da:"Minimer",fi:"Pienennä",no:"Minimer",cs:"Minimalizovat",hu:"Minimalizálás",ro:"Minimizează",sk:"Minimalizovať",hr:"Minimiziraj",bg:"Минимизирай",sl:"Minimiziraj",et:"Minimeeri",lv:"Minimizēt",lt:"Sumažinti",el:"Ελαχιστοποίηση",ru:"Свернуть",uk:"Згорнути",ja:"最小化",zh:"最小化",ko:"최소화",ar:"تصغير",hi:"न्यूनतम करें",id:"Kecilkan",tr:"Küçült",th:"ย่อขนาด",vi:"Thu nhỏ",he:"מזער",fa:"کمینه کردن",ms:"Kecilkan",tl:"Paliitin"},dataPolicy:{en:"Data Policy",de:"Datenschutzrichtlinie",fr:"Politique de données",es:"Política de datos",it:"Politica sui dati",pt:"Política de dados",nl:"Gegevensbeleid",pl:"Polityka danych",sv:"Datapolicy",da:"Datapolitik",fi:"Tietopolitiikka",no:"Datapolicy",cs:"Zásady dat",hu:"Adatkezelési irányelvek",ro:"Politica datelor",sk:"Zásady údajov",hr:"Politika podataka",bg:"Политика за данни",sl:"Politika podatkov",et:"Andmepoliitika",lv:"Datu politika",lt:"Duomenų politika",el:"Πολιτική δεδομένων",ru:"Политика данных",uk:"Політика даних",ja:"データポリシー",zh:"数据政策",ko:"데이터 정책",ar:"سياسة البيانات",hi:"डेटा नीति",id:"Kebijakan Data",tr:"Veri Politikası",th:"นโยบายข้อมูล",vi:"Chính sách dữ liệu",he:"מדיניות נתונים",fa:"سیاست داده",ms:"Dasar Data",tl:"Patakaran sa Data"}},statusMessages:{connecting:{en:"Connecting...",de:"Verbindet...",fr:"Connexion...",es:"Conectando...",it:"Connessione...",pt:"Conectando...",nl:"Verbinden...",pl:"Łączenie...",sv:"Ansluter...",da:"Forbinder...",fi:"Yhdistetään...",no:"Kobler til...",cs:"Připojování...",hu:"Csatlakozás...",ro:"Se conectează...",sk:"Pripájanie...",hr:"Povezivanje...",bg:"Свързване...",sl:"Povezovanje...",et:"Ühendamine...",lv:"Savienojas...",lt:"Jungiamasi...",el:"Σύνδεση...",ru:"Подключение...",uk:"Підключення...",ja:"接続中...",zh:"正在连接...",ko:"연결 중...",ar:"جاري الاتصال...",hi:"कनेक्ट हो रहा है...",id:"Menghubungkan...",tr:"Bağlanıyor...",th:"กำลังเชื่อมต่อ...",vi:"Đang kết nối...",he:"מתחבר...",fa:"در حال اتصال...",ms:"Menyambung...",tl:"Kumukonekta..."},typing:{en:"Typing...",de:"Schreibt...",fr:"Saisie...",es:"Escribiendo...",it:"Scrivendo...",pt:"Digitando...",nl:"Typen...",pl:"Pisze...",sv:"Skriver...",da:"Skriver...",fi:"Kirjoittaa...",no:"Skriver...",cs:"Píše...",hu:"Gépel...",ro:"Scrie...",sk:"Píše...",hr:"Piše...",bg:"Пише...",sl:"Piše...",et:"Kirjutab...",lv:"Raksta...",lt:"Rašo...",el:"Πληκτρολογεί...",ru:"Печатает...",uk:"Друкує...",ja:"入力中...",zh:"正在输入...",ko:"입력 중...",ar:"يكتب...",hi:"टाइप कर रहा है...",id:"Mengetik...",tr:"Yazıyor...",th:"กำลังพิมพ์...",vi:"Đang gõ...",he:"מקליד...",fa:"در حال تایپ...",ms:"Menaip...",tl:"Nagta-type..."}}};function p(){let e="en";try{"undefined"!=typeof navigator&&(e=navigator.language,!e&&navigator.languages&&navigator.languages.length>0&&(e=navigator.languages[0]),!e&&navigator.userLanguage&&(e=navigator.userLanguage),!e&&navigator.browserLanguage&&(e=navigator.browserLanguage),!e&&navigator.systemLanguage&&(e=navigator.systemLanguage)),e&&"string"==typeof e||(e="en"),e=e.split("-")[0].toLowerCase(),/^[a-z]{2,3}$/.test(e)||(e="en")}catch(t){e="en"}return e}function g(e,t=null){const n=t||p();if(!c[e])return{};const i={};for(const t in c[e])i[t]=c[e][t][n]||c[e][t].en||t;return i}function b(e,t=null){const n=t||p();return c[e]&&(c[e][n]||c[e].en)||e} /*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:u,setPrototypeOf:h,isFrozen:m,getPrototypeOf:f,getOwnPropertyDescriptor:v}=Object;let{freeze:y,seal:x,create:w}=Object,{apply:k,construct:S}="undefined"!=typeof Reflect&&Reflect;y||(y=function(e){return e}),x||(x=function(e){return e}),k||(k=function(e,t,n){return e.apply(t,n)}),S||(S=function(e,t){return new e(...t)});const C=W(Array.prototype.forEach),T=W(Array.prototype.lastIndexOf),L=W(Array.prototype.pop),_=W(Array.prototype.push),M=W(Array.prototype.splice),I=W(String.prototype.toLowerCase),z=W(String.prototype.toString),E=W(String.prototype.match),B=W(String.prototype.replace),$=W(String.prototype.indexOf),A=W(String.prototype.trim),P=W(Object.prototype.hasOwnProperty),q=W(RegExp.prototype.test),D=(H=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return S(H,t)});var H;function W(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 k(e,t,i)}}function O(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I;h&&h(e,null);let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(m(t)||(t[i]=e),o=e)}e[o]=!0}return e}function N(e){for(let t=0;t<e.length;t++){P(e,t)||(e[t]=null)}return e}function F(e){const t=w(null);for(const[n,i]of u(e)){P(e,n)&&(Array.isArray(i)?t[n]=N(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=F(i):t[n]=i)}return t}function U(e,t){for(;null!==e;){const n=v(e,t);if(n){if(n.get)return W(n.get);if("function"==typeof n.value)return W(n.value)}e=f(e)}return function(){return null}}const R=y(["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","section","select","shadow","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"]),V=y(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),j=y(["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"]),K=y(["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"]),G=y(["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"]),Y=y(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Z=y(["#text"]),X=y(["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","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Q=y(["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","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"]),J=y(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ee=y(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),te=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ne=x(/<%[\w\W]*|[\w\W]*%>/gm),ie=x(/\$\{[\w\W]*/gm),oe=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),se=x(/^aria-[\-\w]+$/),ae=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),re=x(/^(?:\w+script|data):/i),le=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),de=x(/^html$/i),ce=x(/^[a-z][.\w]*(-[.\w]+)+$/i);var pe=Object.freeze({__proto__:null,ARIA_ATTR:se,ATTR_WHITESPACE:le,CUSTOM_ELEMENT:ce,DATA_ATTR:oe,DOCTYPE_NAME:de,ERB_EXPR:ne,IS_ALLOWED_URI:ae,IS_SCRIPT_OR_DATA:re,MUSTACHE_EXPR:te,TMPLIT_EXPR:ie});const ge=1,be=3,ue=7,he=8,me=9,fe=function(){return"undefined"==typeof window?null:window};var ve=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:fe();const n=t=>e(t);if(n.version="3.2.6",n.removed=[],!t||!t.document||t.document.nodeType!==me||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const o=i,s=o.currentScript,{DocumentFragment:a,HTMLTemplateElement:r,Node:l,Element:d,NodeFilter:c,NamedNodeMap:p=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:g,DOMParser:b,trustedTypes:h}=t,m=d.prototype,f=U(m,"cloneNode"),v=U(m,"remove"),x=U(m,"nextSibling"),k=U(m,"childNodes"),S=U(m,"parentNode");if("function"==typeof r){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let H,W="";const{implementation:N,createNodeIterator:te,createDocumentFragment:ne,getElementsByTagName:ie}=i,{importNode:oe}=o;let se={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof u&&"function"==typeof S&&N&&void 0!==N.createHTMLDocument;const{MUSTACHE_EXPR:re,ERB_EXPR:le,TMPLIT_EXPR:ce,DATA_ATTR:ve,ARIA_ATTR:ye,IS_SCRIPT_OR_DATA:xe,ATTR_WHITESPACE:we,CUSTOM_ELEMENT:ke}=pe;let{IS_ALLOWED_URI:Se}=pe,Ce=null;const Te=O({},[...R,...V,...j,...G,...Z]);let Le=null;const _e=O({},[...X,...Q,...J,...ee]);let Me=Object.seal(w(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}})),Ie=null,ze=null,Ee=!0,Be=!0,$e=!1,Ae=!0,Pe=!1,qe=!0,De=!1,He=!1,We=!1,Oe=!1,Ne=!1,Fe=!1,Ue=!0,Re=!1,Ve=!0,je=!1,Ke={},Ge=null;const Ye=O({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ze=null;const Xe=O({},["audio","video","img","source","image","track"]);let Qe=null;const Je=O({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let it=nt,ot=!1,st=null;const at=O({},[et,tt,nt],z);let rt=O({},["mi","mo","mn","ms","mtext"]),lt=O({},["annotation-xml"]);const dt=O({},["title","style","font","a","script"]);let ct=null;const pt=["application/xhtml+xml","text/html"];let gt=null,bt=null;const ut=i.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},mt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!bt||bt!==e){if(e&&"object"==typeof e||(e={}),e=F(e),ct=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,gt="application/xhtml+xml"===ct?z:I,Ce=P(e,"ALLOWED_TAGS")?O({},e.ALLOWED_TAGS,gt):Te,Le=P(e,"ALLOWED_ATTR")?O({},e.ALLOWED_ATTR,gt):_e,st=P(e,"ALLOWED_NAMESPACES")?O({},e.ALLOWED_NAMESPACES,z):at,Qe=P(e,"ADD_URI_SAFE_ATTR")?O(F(Je),e.ADD_URI_SAFE_ATTR,gt):Je,Ze=P(e,"ADD_DATA_URI_TAGS")?O(F(Xe),e.ADD_DATA_URI_TAGS,gt):Xe,Ge=P(e,"FORBID_CONTENTS")?O({},e.FORBID_CONTENTS,gt):Ye,Ie=P(e,"FORBID_TAGS")?O({},e.FORBID_TAGS,gt):F({}),ze=P(e,"FORBID_ATTR")?O({},e.FORBID_ATTR,gt):F({}),Ke=!!P(e,"USE_PROFILES")&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,Be=!1!==e.ALLOW_DATA_ATTR,$e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ae=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Pe=e.SAFE_FOR_TEMPLATES||!1,qe=!1!==e.SAFE_FOR_XML,De=e.WHOLE_DOCUMENT||!1,Oe=e.RETURN_DOM||!1,Ne=e.RETURN_DOM_FRAGMENT||!1,Fe=e.RETURN_TRUSTED_TYPE||!1,We=e.FORCE_BODY||!1,Ue=!1!==e.SANITIZE_DOM,Re=e.SANITIZE_NAMED_PROPS||!1,Ve=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,Se=e.ALLOWED_URI_REGEXP||ae,it=e.NAMESPACE||nt,rt=e.MATHML_TEXT_INTEGRATION_POINTS||rt,lt=e.HTML_INTEGRATION_POINTS||lt,Me=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Me.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Me.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Me.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Pe&&(Be=!1),Ne&&(Oe=!0),Ke&&(Ce=O({},Z),Le=[],!0===Ke.html&&(O(Ce,R),O(Le,X)),!0===Ke.svg&&(O(Ce,V),O(Le,Q),O(Le,ee)),!0===Ke.svgFilters&&(O(Ce,j),O(Le,Q),O(Le,ee)),!0===Ke.mathMl&&(O(Ce,G),O(Le,J),O(Le,ee))),e.ADD_TAGS&&(Ce===Te&&(Ce=F(Ce)),O(Ce,e.ADD_TAGS,gt)),e.ADD_ATTR&&(Le===_e&&(Le=F(Le)),O(Le,e.ADD_ATTR,gt)),e.ADD_URI_SAFE_ATTR&&O(Qe,e.ADD_URI_SAFE_ATTR,gt),e.FORBID_CONTENTS&&(Ge===Ye&&(Ge=F(Ge)),O(Ge,e.FORBID_CONTENTS,gt)),Ve&&(Ce["#text"]=!0),De&&O(Ce,["html","head","body"]),Ce.table&&(O(Ce,["tbody"]),delete Ie.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw D('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw D('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');H=e.TRUSTED_TYPES_POLICY,W=H.createHTML("")}else void 0===H&&(H=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 null}}(h,s)),null!==H&&"string"==typeof W&&(W=H.createHTML(""));y&&y(e),bt=e}},ft=O({},[...V,...j,...K]),vt=O({},[...G,...Y]),yt=function(e){_(n.removed,{element:e});try{S(e).removeChild(e)}catch(t){v(e)}},xt=function(e,t){try{_(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){_(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Oe||Ne)try{yt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},wt=function(e){let t=null,n=null;if(We)e="<remove></remove>"+e;else{const t=E(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ct&&it===nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=H?H.createHTML(e):e;if(it===nt)try{t=(new b).parseFromString(o,ct)}catch(e){}if(!t||!t.documentElement){t=N.createDocument(it,"template",null);try{t.documentElement.innerHTML=ot?W:o}catch(e){}}const s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),it===nt?ie.call(t,De?"html":"body")[0]:De?t.documentElement:s},kt=function(e){return te.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},St=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Ct=function(e){return"function"==typeof l&&e instanceof l};function Tt(e,t,i){C(e,(e=>{e.call(n,t,i,bt)}))}const Lt=function(e){let t=null;if(Tt(se.beforeSanitizeElements,e,null),St(e))return yt(e),!0;const i=gt(e.nodeName);if(Tt(se.uponSanitizeElement,e,{tagName:i,allowedTags:Ce}),qe&&e.hasChildNodes()&&!Ct(e.firstElementChild)&&q(/<[/\w!]/g,e.innerHTML)&&q(/<[/\w!]/g,e.textContent))return yt(e),!0;if(e.nodeType===ue)return yt(e),!0;if(qe&&e.nodeType===he&&q(/<[/\w]/g,e.data))return yt(e),!0;if(!Ce[i]||Ie[i]){if(!Ie[i]&&Mt(i)){if(Me.tagNameCheck instanceof RegExp&&q(Me.tagNameCheck,i))return!1;if(Me.tagNameCheck instanceof Function&&Me.tagNameCheck(i))return!1}if(Ve&&!Ge[i]){const t=S(e)||e.parentNode,n=k(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const o=f(n[i],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,x(e))}}}return yt(e),!0}return e instanceof d&&!function(e){let t=S(e);t&&t.tagName||(t={namespaceURI:it,tagName:"template"});const n=I(e.tagName),i=I(t.tagName);return!!st[e.namespaceURI]&&(e.namespaceURI===tt?t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===i||rt[i]):Boolean(ft[n]):e.namespaceURI===et?t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&lt[i]:Boolean(vt[n]):e.namespaceURI===nt?!(t.namespaceURI===tt&&!lt[i])&&!(t.namespaceURI===et&&!rt[i])&&!vt[n]&&(dt[n]||!ft[n]):!("application/xhtml+xml"!==ct||!st[e.namespaceURI]))}(e)?(yt(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!q(/<\/no(script|embed|frames)/i,e.innerHTML)?(Pe&&e.nodeType===be&&(t=e.textContent,C([re,le,ce],(e=>{t=B(t,e," ")})),e.textContent!==t&&(_(n.removed,{element:e.cloneNode()}),e.textContent=t)),Tt(se.afterSanitizeElements,e,null),!1):(yt(e),!0)},_t=function(e,t,n){if(Ue&&("id"===t||"name"===t)&&(n in i||n in ut))return!1;if(Be&&!ze[t]&&q(ve,t));else if(Ee&&q(ye,t));else if(!Le[t]||ze[t]){if(!(Mt(e)&&(Me.tagNameCheck instanceof RegExp&&q(Me.tagNameCheck,e)||Me.tagNameCheck instanceof Function&&Me.tagNameCheck(e))&&(Me.attributeNameCheck instanceof RegExp&&q(Me.attributeNameCheck,t)||Me.attributeNameCheck instanceof Function&&Me.attributeNameCheck(t))||"is"===t&&Me.allowCustomizedBuiltInElements&&(Me.tagNameCheck instanceof RegExp&&q(Me.tagNameCheck,n)||Me.tagNameCheck instanceof Function&&Me.tagNameCheck(n))))return!1}else if(Qe[t]);else if(q(Se,B(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==$(n,"data:")||!Ze[e]){if($e&&!q(xe,B(n,we,"")));else if(n)return!1}else;return!0},Mt=function(e){return"annotation-xml"!==e&&E(e,ke)},It=function(e){Tt(se.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||St(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Le,forceKeepAttr:void 0};let o=t.length;for(;o--;){const s=t[o],{name:a,namespaceURI:r,value:l}=s,d=gt(a),c=l;let p="value"===a?c:A(c);if(i.attrName=d,i.attrValue=p,i.keepAttr=!0,i.forceKeepAttr=void 0,Tt(se.uponSanitizeAttribute,e,i),p=i.attrValue,!Re||"id"!==d&&"name"!==d||(xt(a,e),p="user-content-"+p),qe&&q(/((--!?|])>)|<\/(style|title)/i,p)){xt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){xt(a,e);continue}if(!Ae&&q(/\/>/i,p)){xt(a,e);continue}Pe&&C([re,le,ce],(e=>{p=B(p,e," ")}));const g=gt(e.nodeName);if(_t(g,d,p)){if(H&&"object"==typeof h&&"function"==typeof h.getAttributeType)if(r);else switch(h.getAttributeType(g,d)){case"TrustedHTML":p=H.createHTML(p);break;case"TrustedScriptURL":p=H.createScriptURL(p)}if(p!==c)try{r?e.setAttributeNS(r,a,p):e.setAttribute(a,p),St(e)?yt(e):L(n.removed)}catch(t){xt(a,e)}}else xt(a,e)}Tt(se.afterSanitizeAttributes,e,null)},zt=function e(t){let n=null;const i=kt(t);for(Tt(se.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)Tt(se.uponSanitizeShadowNode,n,null),Lt(n),It(n),n.content instanceof a&&e(n.content);Tt(se.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,r=null,d=null;if(ot=!e,ot&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ct(e)){if("function"!=typeof e.toString)throw D("toString is not a function");if("string"!=typeof(e=e.toString()))throw D("dirty is not a string, aborting")}if(!n.isSupported)return e;if(He||mt(t),n.removed=[],"string"==typeof e&&(je=!1),je){if(e.nodeName){const t=gt(e.nodeName);if(!Ce[t]||Ie[t])throw D("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)i=wt("\x3c!----\x3e"),s=i.ownerDocument.importNode(e,!0),s.nodeType===ge&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s);else{if(!Oe&&!Pe&&!De&&-1===e.indexOf("<"))return H&&Fe?H.createHTML(e):e;if(i=wt(e),!i)return Oe?null:Fe?W:""}i&&We&&yt(i.firstChild);const c=kt(je?e:i);for(;r=c.nextNode();)Lt(r),It(r),r.content instanceof a&&zt(r.content);if(je)return e;if(Oe){if(Ne)for(d=ne.call(i.ownerDocument);i.firstChild;)d.appendChild(i.firstChild);else d=i;return(Le.shadowroot||Le.shadowrootmode)&&(d=oe.call(o,d,!0)),d}let p=De?i.outerHTML:i.innerHTML;return De&&Ce["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&q(de,i.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+p),Pe&&C([re,le,ce],(e=>{p=B(p,e," ")})),H&&Fe?H.createHTML(p):p},n.setConfig=function(){mt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),He=!0},n.clearConfig=function(){bt=null,He=!1},n.isValidAttribute=function(e,t,n){bt||mt({});const i=gt(e),o=gt(t);return _t(i,o,n)},n.addHook=function(e,t){"function"==typeof t&&_(se[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=T(se[e],t);return-1===n?void 0:M(se[e],n,1)[0]}return L(se[e])},n.removeHooks=function(e){se[e]=[]},n.removeAllHooks=function(){se={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();class ye{constructor(){this.allowedCSSProperties=["color","background-color","background","font-family","font-size","font-weight","line-height","text-align","margin","padding","border","border-radius","box-shadow","opacity","transition","transform","animation","display","flex","gap","width","max-width","min-width","height","max-height","min-height"],this.blockedCSSPatterns=[/expression\(/i,/javascript:/i,/vbscript:/i,/onload/i,/onerror/i,/onclick/i,/@import/i,/position\s*:\s*fixed/i,/z-index\s*:\s*99999/i],this.configureDOMPurify()}configureDOMPurify(){this.purifyConfig={ALLOWED_TAGS:["div","span","p","br","strong","em","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","code","pre"],ALLOWED_ATTR:["class","id","href","src","alt","title"],FORBID_TAGS:["style","script","iframe","form","input"],FORBID_ATTR:["style","onclick","onerror","onload"]}}sanitizeCSS(e){if(!e||"string"!=typeof e)return"";e=e.replace(/\/\*[\s\S]*?\*\//g,"");for(const t of this.blockedCSSPatterns)if(t.test(e))return"";const t=[],n=/([^{]+)\{([^}]+)\}/g;let i;for(;null!==(i=n.exec(e));){const e=i[1].trim(),n=i[2].trim();if(!e.includes(".besper-"))continue;const o=this.sanitizeProperties(n);o&&t.push(`${e} { ${o} }`)}return t.join("\n")}sanitizeProperties(e){const t=e.split(";").filter((e=>e.trim())),n=[];for(const e of t){const t=e.indexOf(":");if(-1===t)continue;const i=e.slice(0,t).trim(),o=e.slice(t+1).trim();this.allowedCSSProperties.includes(i)&&this.isValidPropertyValue(i,o)&&n.push(`${i}: ${o}`)}return n.join("; ")}isValidPropertyValue(e,t){return e.includes("color")?this.isValidColor(t):["font-size","width","height","padding","margin"].includes(e)?this.isValidSize(t):"font-family"!==e||this.isValidFontFamily(t)}isValidColor(e){return[/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/,/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[\d.]+\s*\)$/].some((t=>t.test(e)))||["white","black","red","green","blue","yellow","transparent","currentColor"].includes(e.toLowerCase())}isValidSize(e){return/^\d+(\.\d+)?(px|em|rem|%|vh|vw)$/.test(e)||["auto","inherit","initial"].includes(e)}isValidFontFamily(e){const t=e.replace(/['"]/g,"");return!/[<>{}();]/.test(t)}sanitizeHTML(e){return e&&"string"==typeof e?ve.sanitize(e,this.purifyConfig):""}}let xe=class{constructor(e,t={}){this.botId=e,this.options={environment:"prod",position:"bottom-right",...t},this.state={isOpen:!1,isMinimized:!0,threadId:null,isConnected:!1,sessionData:null,styling:null,botConfig:null,typing:!1,viewState:"normal",userLanguage:p(),isMobileFullscreen:!1},this.messageHistory=[],this.widget=null,this.apiEndpoint=i(),this.isInitialized=!1,this.autoExpandTimeouts=new Map,this.outsideClickHandler=null,this.customMessageTemplate=null,this.sanitizer=new ye,this.isMobile=this.detectMobile()}detectMobile(){const e=navigator.userAgent||navigator.vendor||window.opera,t=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(e.toLowerCase()),n="ontouchstart"in window||navigator.maxTouchPoints>0,i=window.innerWidth<=768;return t||n&&i}async init(){try{try{await this.createSession(),this.applySessionConfiguration()}catch(e){this.applyDefaultConfiguration(e)}return this.createWidget(),this.state.isConnected?this.addWelcomeMessage():this.addOfflineMessage(),this.setupEventHandlers(),this.setupOutsideClickHandler(),this.isMobileDevice()&&(window.addEventListener("orientationchange",(()=>{setTimeout((()=>{this.adjustMobileLayout()}),500)})),window.visualViewport&&window.visualViewport.addEventListener("resize",(()=>{setTimeout((()=>{this.adjustMobileLayout()}),100)})),window.addEventListener("resize",(()=>{this.isMobileDevice()&&setTimeout((()=>{this.adjustMobileLayout()}),100)}))),this.isInitialized=!0,this}catch(e){throw e}}async createSession(){try{const e=p(),t=await l("create_session","POST",{bot_id:this.botId,implementation_type:"widget",browser_language:e},this.options.environment);if(!t.success)throw new Error(t.error||"Session creation failed");this.state.sessionData=t,this.state.threadId=t.thread_id||t.session_token,this.state.isConnected=!0,this.state.styling=t.styling||{},this.state.botConfig={botName:t.bot_name||t.bot_title||"B-esper Assistant",botTitle:t.bot_title||"AI Assistant",welcomeMessage:t.welcome_message,dataPolicyUrl:t.data_policy_url,logoUrl:t.logo||t.styling?.logo_url}}catch(e){this.state.threadId="demo-"+Date.now(),this.state.isConnected=!1,this.state.styling={primary_color:"#5897de",secondary_color:"#022d54",user_message_color:"#5897de",bot_message_color:"#f0f4f8",font_family:"Segoe UI"},this.state.botConfig={botName:"Demo Assistant",botTitle:"Demo Mode",welcomeMessage:"Demo mode: API connection failed. This is a demo interface.",dataPolicyUrl:null,logoUrl:null}}}createWidget(){this.options.container?this.createEmbeddedWidget():this.createFloatingWidget(),this.injectStyles()}createFloatingWidget(){const e=document.createElement("div");e.id="besper-chat-widget",e.className="besper-widget-container",this.positionWidget(e),e.innerHTML=this.getWidgetHTML(),document.body.appendChild(e),this.widget=e}createEmbeddedWidget(){let e;if("string"==typeof this.options.container?e=document.getElementById(this.options.container)||document.querySelector(this.options.container):this.options.container instanceof HTMLElement&&(e=this.options.container),!e)throw new Error(`Container not found: ${this.options.container}`);const t=document.createElement("div");t.id="besper-chat-widget",t.className="besper-widget-container besper-embedded",t.style.position="relative",t.style.width="100%",t.style.height="100%",t.style.minHeight="400px",t.innerHTML=this.getEmbeddedWidgetHTML(),e.appendChild(t),this.widget=t,this.state.isOpen=!0,this.state.isMinimized=!1}positionWidget(e){const t=this.options.position||"bottom-right";switch(e.style.position="fixed",e.style.zIndex="9999",t){case"bottom-right":e.style.bottom="20px",e.style.right="20px";break;case"bottom-left":e.style.bottom="20px",e.style.left="20px";break;case"top-right":e.style.top="20px",e.style.right="20px";break;case"top-left":e.style.top="20px",e.style.left="20px"}}getWidgetHTML(){const e=this.state.botConfig,t=g("tooltips",this.state.userLanguage),n=b("typeYourMessage",this.state.userLanguage);return`\n <div class="besper-widget ${this.state.isOpen?"open":"minimized"}">\n \x3c!-- Minimized Widget Button --\x3e\n <div class="besper-widget-button" id="besper-widget-btn">\n <div class="besper-widget-icon">\n${e.logoUrl?`<img src="${e.logoUrl}" alt="Bot Logo" class="besper-widget-logo">`:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"></path>\n </svg>'}\n </div>\n </div>\n\n \x3c!-- Chat Interface --\x3e\n <div class="besper-chat-container" id="besper-chat-container">\n \x3c!-- Header (logo removed from here as per requirement) --\x3e\n <div class="besper-chat-header">\n <div class="besper-chat-header-left">\n <div class="besper-chat-title-group">\n <div class="besper-chat-title">${e.botTitle}</div>\n </div>\n </div>\n <div class="besper-chat-header-right">\n <div class="besper-chat-actions">\n ${e.dataPolicyUrl?`\n <button type="button" class="besper-action-btn" id="besper-data-policy-btn" title="${t.dataPolicy}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>\n </svg>\n </button>\n `:""}\n <button type="button" class="besper-action-btn" id="besper-expand-btn" title="${t.expandView}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>\n </svg>\n </button>\n <button type="button" class="besper-action-btn" id="besper-download-btn" title="${t.downloadConversation}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7,10 12,15 17,10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>\n </button>\n <button type="button" class="besper-action-btn" id="besper-restart-btn" title="${t.restartConversation}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M1 4v6h6"/>\n <path d="M23 20v-6h-6"/>\n <path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10"/>\n <path d="M3.51 15a9 9 0 0 0 14.85 3.36L23 14"/>\n </svg>\n </button>\n <button type="button" class="besper-action-btn" id="besper-delete-btn" title="${t.deleteConversation}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M3 6h18"/>\n <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>\n <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/>\n </svg>\n </button>\n <button type="button" class="besper-action-btn" id="besper-minimize-btn" title="${t.minimizeChat}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M6 9l6 6 6-6"/>\n </svg>\n </button>\n </div>\n </div>\n </div>\n \n \x3c!-- Messages Area --\x3e\n <div class="besper-chat-messages" id="besper-messages">\n \x3c!-- Messages and typing indicator will be dynamically added here --\x3e\n </div>\n \n \x3c!-- Input Area --\x3e\n <div class="besper-chat-input-container">\n <form class="besper-chat-input-form" id="besper-chat-form">\n <div class="besper-input-wrapper">\n <textarea \n class="besper-chat-input" \n id="besper-message-input" \n placeholder="${n}"\n rows="1"\n maxlength="2000"\n ></textarea>\n </div>\n <button type="submit" class="besper-chat-send-btn" id="besper-send-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="22" y1="2" x2="11" y2="13"></line>\n <polygon points="22,2 15,22 11,13 2,9 22,2"></polygon>\n </svg>\n </button>\n </form>\n </div>\n </div>\n </div>\n `}getEmbeddedWidgetHTML(){const e=this.state.botConfig,t=g("tooltips",this.state.userLanguage),n=b("typeYourMessage",this.state.userLanguage),i=b("tapToStartChat",this.state.userLanguage);return`\n <div class="besper-widget embedded open">\n ${this.isMobile&&this.options.container?`\n <div class="besper-mobile-overlay" id="besper-mobile-overlay">\n <div class="besper-mobile-overlay-content">\n <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>\n </svg>\n <p>${i}</p>\n </div>\n </div>\n `:""}\n \x3c!-- Chat Interface (no floating button for embedded mode) --\x3e\n <div class="besper-chat-container" id="besper-chat-container">\n \x3c!-- Header --\x3e\n <div class="besper-chat-header">\n <div class="besper-chat-header-left">\n <div class="besper-chat-title-group">\n ${e.logoUrl?`<div class="besper-chat-logo">\n <img src="${e.logoUrl}" alt="Bot Logo" class="besper-chat-logo-img">\n </div>`:""}\n <div class="besper-chat-title">${e.botTitle}</div>\n </div>\n </div>\n <div class="besper-chat-header-right">\n <div class="besper-chat-actions">\n ${e.dataPolicyUrl?`\n <button type="button" class="besper-action-btn" id="besper-data-policy-btn" title="${t.dataPolicy}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>\n </svg>\n </button>\n `:""}\n \x3c!-- Expand button removed for embedded/container mode --\x3e\n <button type="button" class="besper-action-btn" id="besper-download-btn" title="${t.downloadConversation}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7,10 12,15 17,10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>\n </button>\n <button type="button" class="besper-action-btn" id="besper-restart-btn" title="${t.restartConversation}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M1 4v6h6"/>\n <path d="M23 20v-6h-6"/>\n <path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10"/>\n <path d="M3.51 15a9 9 0 0 0 14.85 3.36L23 14"/>\n </svg>\n </button>\n <button type="button" class="besper-action-btn" id="besper-delete-btn" title="${t.deleteConversation}">\n <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <path d="M3 6h18"/>\n <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>\n <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/>\n </svg>\n </button>\n </div>\n </div>\n </div>\n \n \x3c!-- Messages Area --\x3e\n <div class="besper-chat-messages" id="besper-messages">\n \x3c!-- Messages and typing indicator will be dynamically added here --\x3e\n </div>\n \n \x3c!-- Input Area --\x3e\n <div class="besper-chat-input-container">\n <form class="besper-chat-input-form" id="besper-chat-form">\n <div class="besper-input-wrapper">\n <textarea \n class="besper-chat-input" \n id="besper-message-input" \n placeholder="${n}"\n rows="1"\n maxlength="2000"\n ></textarea>\n </div>\n <button type="submit" class="besper-chat-send-btn" id="besper-send-btn">\n <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n <line x1="22" y1="2" x2="11" y2="13"></line>\n <polygon points="22,2 15,22 11,13 2,9 22,2"></polygon>\n </svg>\n </button>\n </form>\n </div>\n </div>\n </div>\n `}setupEventHandlers(){const e=this.widget.querySelector("#besper-widget-btn"),t=this.widget.querySelector("#besper-minimize-btn"),n=this.widget.querySelector("#besper-send-btn"),i=this.widget.querySelector("#besper-message-input"),o=this.widget.querySelector("#besper-chat-form"